-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC: Update interactive colormap example #21236
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
zoom_axes = ["2d", "color zoom in", "color zoom out"] | ||
pan_axes = ["2d", "color pan up", "color pan down"] | ||
|
||
fig, ax_dict = plt.subplot_mosaic( | ||
[ | ||
zoom_axes, | ||
pan_axes | ||
], | ||
constrained_layout=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the multitude of axes rather confusing. AFAICS they only differ in their initial clim values. I assume that's intended to give a good starting point for the respective interactions. However, all operation work reasonably well when starting on the "2d" image. It think it's better to have only the one image and let the user try all operations on that image.
I also found that panning on the image was really slow, likely because varying tick labels cause the constrained_layout solver to kick in again. One would have to deactivate constrained_layout after the first draw. But that's also obsolete if we can get away with one image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 The reason for that was to demonstrate what the outcome of zooming/panning would do in each of the cases, but perhaps you're right it would be better to just let someone start interacting with the image and see for themselves. I updated this to have 3 images now with data ranges that are under/normal/over to try and get the sense that you can interact with the colorbar to identify new data regions.
Let me know what you think of this approach... Happy to go to just 1 image as well if you think that would be more clear.
examples/images_contours_and_fields/colormap_interactive_adjustment.py
Outdated
Show resolved
Hide resolved
examples/images_contours_and_fields/colormap_interactive_adjustment.py
Outdated
Show resolved
Hide resolved
68cbc97
to
b01d5c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be enough:
fig, ax = plt.subplots()
im = ax.imshow(data2d)
fig.colorbar(im, ax=ax)
ax.set_title('Pan on the colorbar to shift the mapping data -> color\nZoom on the colorbar to scale the mapping data -> color ')
plt.show()
Since the gallery is static by nature, we simply cannot show interactivity. IMHO the best we can do is to have a simple example and tell the readers what they should try themselves.
If you really want to do more, I suggest to show some example images additionally:
- This is the result after shifting the colorbar scale up: [image]
- This is the result of zooming in: [image]
- This is the result of zooming out: [image]
Maybe even use the image directive to hide the code, because having code that produces the same result as your interactivity is rather confusing.
b01d5c6
to
adace6d
Compare
OK, I went with your suggestion to keep it simple. I changed "mapping data -> color" to "norm" as that seems easier to read. I agree that it is tough to demonstrate interactivity, and I'm not sure how many people even know all of the options for interactivity! I know I personally keep learning new things just by stumbling upon them. Perhaps a solution could be to add a tutorial page with some screen recorded gifs of people using the interactive features... |
While technically correct, "norm" requires at least mid-level knowledge of Matplotlib. Users only using
That'd be a really cool thing 😀 |
The colormaps have interactivity with zoom/pan now, so demonstrate what those modes do with the new example. This is instead of using callbacks and mouse events for updates.
adace6d
to
2e7a052
Compare
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove If these instruction are inaccurate, feel free to suggest an improvement. |
…on-v3.5.x Backport PR #21236: DOC: Update interactive colormap example
…xample DOC: Update interactive colormap example
DOC: Update interactive colormap example
PR Summary
The colormaps have interactivity with zoom/pan now, so demonstrate what those modes do with this new example. This is instead of using callbacks and mouse events for updates that were used in the previous example.
Example modified from: #19515 (comment)
xref: #19515 and #20471
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).