-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow colorbar.ax.set_ylim to set the colorbar limits? #13948
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
What’s supposed to happen if limits are set smaller? Also what version are you using above? |
On master, your code produces It seems, you have used I don't know what the suggested way of working with colorbar is right now. However, manipulating |
You can't do this just by changing the x-limit of the underlying axes because the colorbar is represented by a Its totally possible to add this extra API, but I'm skeptical whether its worth the substantial complexity, versus just truncating the colormap. |
Yes, that's I ran this with master (fetched ~2 weeks ago, |
If anyone takes this up please remember that the colorbars also have the extend arrows on the end. This would have to interact with those properly. However I’ll again say that I’m not sure the API complexity needed is worth it. |
I share @jklymak's skepticism about cost/benefit ratio for this. Colorbars are already pretty complicated. |
Supporting this change.
In this image, a diverging colormap is used to differentiate positive and negative values. The negative values are due to some noise. The colorbar falsely conveys the information that the lower limit of the data is comparable to its upper limit. It also requires lots of unnecessary space, which is often a problem in real contexts. Using
I couldn't find any simple workaround, short of rebuilding a custom colormap. |
I think people aknowledge the problem, but there is no definitive solution to it. Possible solutions are:
The discourse thread also contains workarounds using solutions 2. and 3. Those should allow users to get the desired functionality. |
I strongly disagree that the colorbar falsely conveys that there is just as much negative as positive data in the above plot. That’s the image’s job. The colorbar shown above shows me quite clearly that a properly centred diverging colormap has been used, and indicates the range that has been assigned to each side of zero. the data shows me that most of the data is greater than zero. If the ranges were assymetric I’d need to search around for zero to make sure it was properly zeroed (you may or may not be surprised by how many people don’t bother to centre diverging colormaps) and then I’d need to squint to make sure the colorscale for the two signs is symmetric. |
While I actually would prefer this feature, my understanding is that somebody could convey what was desired by making a custom color map. I believe that's what is discussed here: https://stackoverflow.com/questions/41916204/specify-boundaries-on-matplotlib-colorbar |
This is mostly closed by #20054, but there should be tests if we decide to keep this as a "feature"... |
This was closed by #20054. |
Bug report
Bug summary
Coming from this stackoverflow question I was wondering if it would be useful to allow the limits of the colorbar axes to be used for restricting the range of colors to be shown in the colorbar. I.e.
Code for reproduction
Actual outcome
Expected outcome
The text was updated successfully, but these errors were encountered: