-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate linking mappables without data to a colormap #20630
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
Conversation
If a mappable does not provide data for mapping via get_array(), it makes no sense to allow linking it to a colormap. Closes matplotlib#20576
But we should also check the dims of the array? |
Indeed. This is more difficult than I thought, and possibly, our API is not consistent:
This means we likely need some If anybody wants to pick this up, please post here. I'm not clear if I will have time to investigate in time for 3.5. |
If For |
Just a note that I do sometimes make empty ScalarMappables just to make a defined colorbar without explicit linking to an image, so I'm not sure demanding an array should be a requirement. sm = mpl.cm.ScalarMappable(norm=norm, cmap=cmap)
fig.colorbar(sm) I do vaguely remember I used to have to force the array to something in the past ( |
OK, so maybe there is something we can detect when we create the scalar mappable. In that case you have well-defined the norm and cmap. For an RGBA image the user could define those, but probably is not. |
I can't really say but I suppose it not a simple 1:1 relationship. In the two above examples only one has an array, but neither is colormapped. There's also special-casing for
Indeed after looking up, this is the documented solution. There is however the possibility for The current code is not clear as we can see from the confusion on |
Yes, getting all this sorted out before something like #19515 seems important. Currently if we just do norm = mpl.colors.Normalize(vmin=-1, vmax=1)
fig, ax = plt.subplots()
pc = ax.pcolormesh(np.random.randn(20, 20), norm=norm)
fig.colorbar(pc)
norm.vmin = 0
plt.show() 3.4.2MasterI prefer the master behaviour, but the limits of the colorbar are not modified at draw time. Anyhow just an example of how this stuff is not properly sorted out for playing around with in real time. |
Yes, updates / change events is a whole additional dimension. |
See #19553 for the updates portion of this discussion ;) With that PR, the Colorbar norm gets updated to reflect the vmin and there are no lower ticks. |
If a mappable does not provide data for mapping via get_array(), it
makes no sense to allow linking it to a colormap.
Closes #20576