New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New colormaps : Inferno, Viridis, ... #5883
Comments
What is your use case that you need a |
Well, it is just that in the detailed example above, cmap is now being a ListedColormap object instead of usually being a LinearSegmentedColormap. In that case I cannot do: |
I think this accomplishes what you want, doesn't it? from matplotlib.cm import inferno
import numpy as np
nbcurves = 20
colors = inferno(np.arange(nbcurves)) |
Thank you very much for your answer. It gives back that error:
|
Have you tried with 1.5.1? The code from @efiring seems to work for me as well. |
Yes, I am really sorry, my bad, you are right, no bug. In that case, |
My mistake, but one small change fixes it. Use colors = inferno(np.arange(20, dtype=float)) |
Thanks again, but it seems it still does not work, it gives me back a list of colors with the first element being black (one edge of the colormap), then the second element and the 18 others are pale yellow (the other edge of the colormap I guess). |
You can try: colors = inferno(np.linspace(0, inferno.N, nbcolors)) |
Hmm, no, I should probably have tested that out, since it doesn't work either... |
Thanks again, I am deeply sorry to bother you with that. Yes it still does not work, I get the same result as my last message as you said. |
OK, I still wasn't thinking straight. Do this: colors = inferno(np.linspace(0, 1, nbcolors)) |
That is perfect! Solved :). Thank you very much for your precious help! |
Hi,
I wanted to try today the new exciting colormaps that come with the 1.5.0 version of Matplotlib. I quickly discovered I could not use them the same as the previous colormaps. Indeed, in the past I used to do:
Now with the new colormaps I do the same:
where cmap is now a ListedColormap and I cannot do what I used to do before.
My first question would be : why this difference between old and new colormaps?
Then, is there a way I could get a LinearSegmentedColormap from Inferno, Viridis, etc... ? This is really what I want.
Thanks a lot for your time and considering this issue!
The text was updated successfully, but these errors were encountered: