-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: String contour(colors)
gives confusing error when extend
used
#28782
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
Comments
Thanks for the report @lucyleeow! I have reproduced this with our |
Actually, now I look again, this seems to only be an issue if using extend is not meaningful with |
contour(colors)
only works if levels
same length as stringcontour(colors)
gives confusing error when extend
used
Ah yes you're right. I think I was confused because it seems that Maybe |
It's pretty hard to see what these two things have to do with each other. We definitely should clean this up |
I have now learned that we can't just ignore extend for https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/tests/baseline_images/test_colorbar/contour_colorbar.png So I guess we do need to fix single-colour support? |
That is a nutty use of a colorbar, but I think we do need to keep supporting it. Isn't it the case that a single string will always be a colorspec? We aren't going to allow a spec like 'rgbyk' to represent |
I agree: 'rgbyk' should not be a valid color spec. |
Bug summary
contour
(and friends) specify that a single string can be passed tocolors
:But this only works when
levels
is the same length as the color string.Code for reproduction
Actual outcome
colors='green'
gives error (whilecolors='red'
works, or makinglevels
to be length of 5 also works):Expected outcome
Does not depend on color string length.
Additional information
I think it is because we don't convert to list if
colors
is given as string, and then we do this:matplotlib/lib/matplotlib/contour.py
Lines 835 to 836 in ef32d22
Operating system
Ubuntu
Matplotlib Version
3.9.2
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
The text was updated successfully, but these errors were encountered: