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
Problem with discrete ListedColormaps
when more than 4 colors are present
#7103
Comments
That's a pretty long and complicated SSCCE! |
Thanks for looking into this, I really appreciate it. Sorry about the lengthy example, I tried to come up with a smaller toy example but could reproduce the issue I encountered that was present in the longer toy example that I posted. The reason why I thought that this was a bug was that it seemed to work if less than 5 unique integers were present in the I tried your suggestions but couldn't get it to work quite yet.
I tried the
(tried both I may have to read more on this and the alternative solutions. Right now, pcolormesh seems to work fine for this application although less visually appealing. Sorry for the additional trouble, but if you think that this behavior is indeed not a bug, please close this issue. |
At a minimum it should be better documented. |
@tacaswell Thanks for the feedback!
Are you referring to the |
Sorry, I meant |
Oh, I see! So this is indeed expected behavior (and I was just lucky that it worked for the first example (up to 4 integers in that array)? I'll look into other solutions then. I wish I could help with the documentation of |
I am also not sure if this is the expected behavior, hence it should be documented better ;) You may want to look at |
Sorry, I was not thinking about the contourf case even though it was right in front of me.
This illustrates contouring when you have a listed colormap of 5 colors, and you have 5 consecutive integer values starting from zero. With contouring, it is almost always a good idea to supply the levels (the contour boundaries) explicitly. |
@efiring great, it works perfectly. Thanks a lot! |
@efiring Is there obvious documenting to be done here or should this be closed with no action? |
I was forgetting that the easy way to handle this is to let |
To help us understand and resolve your issue please check that you have provided
the information below.
conda update matplotlib
that demonstrates the issue i.e a small piece of code which reproduces the issue
and can be run with out any other (or as few as possible) external dependencies.
However, a continuous colormap works fine, e.g.,
viridis
. So I suspect that there's a bug inListedColormap
I.e., using the colormap
viridis
inplt.contourf(xx1, xx2, Z, alpha=0.4, cmap='viridis')
produces expected results:note where it used to work.
The text was updated successfully, but these errors were encountered: