Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

greglucas
Copy link
Contributor

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

  • [N/A] Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • [N/A] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@greglucasgreglucas added this to thev3.5.0 milestoneSep 30, 2021
Comment on lines 33 to 42
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,
)
Copy link
Member

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.

Copy link
ContributorAuthor

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.

@jklymakjklymak modified the milestones:v3.5.0,v3.5.1Oct 1, 2021
@greglucasgreglucasforce-pushed thecmap-interactive-example branch from68cbc97 tob01d5c6CompareOctober 1, 2021 14:24
Copy link
Member

@timhoffmtimhoffm left a 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()

grafik

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 youreally 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.

@greglucasgreglucasforce-pushed thecmap-interactive-example branch fromb01d5c6 toadace6dCompareOctober 1, 2021 22:12
@greglucas
Copy link
ContributorAuthor

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...

@timhoffm
Copy link
Member

I changed "mapping data -> color" to "norm" as that seems easier to read.

While technically correct, "norm" requires at least mid-level knowledge of Matplotlib. Users only usingimshow(..., vmin= ..., vmax=...) likely won't know what a "norm" is. Can we find a phrase that's also understandable for inexperienced users? Maybe "... to shift the color mapping"? (somewhat imprecise, but I think ti would get the idea across).

Perhaps a solution could be to add a tutorial page with some screen recorded gifs of people using the interactive features...

That'd be a really cool thing 😀

greglucas reacted with thumbs up emoji

The colormaps have interactivity with zoom/pan now, so demonstratewhat those modes do with the new example. This is instead of usingcallbacks and mouse events for updates.
@greglucasgreglucasforce-pushed thecmap-interactive-example branch fromadace6d to2e7a052CompareOctober 1, 2021 22:56
@timhoffmtimhoffm modified the milestones:v3.5.1,v3.5.0Oct 2, 2021
@timhoffmtimhoffm merged commit5431e38 intomatplotlib:masterOct 2, 2021
@lumberbot-app
Copy link

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.5.x$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 5431e3888db24e57a4856d14fca9eb2d065cfd53
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #21236: DOC: Update interactive colormap example'
  1. Push to a named branch :
git push YOURFORK v3.5.x:auto-backport-of-pr-21236-on-v3.5.x
  1. Create a PR against branch v3.5.x, I would have named this PR:

"Backport PR#21236 on branch v3.5.x (DOC: Update interactive colormap example)"

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 removeStill Needs Manual Backport label once the PR gets merged.

If these instruction are inaccurate, feel free tosuggest an improvement.

greglucas pushed a commit to greglucas/matplotlib that referenced this pull requestOct 2, 2021
@greglucasgreglucas deleted the cmap-interactive-example branchOctober 2, 2021 14:01
timhoffm added a commit that referenced this pull requestOct 3, 2021
…on-v3.5.xBackport PR#21236: DOC: Update interactive colormap example
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull requestOct 12, 2021
…xampleDOC: Update interactive colormap example
tacaswell pushed a commit that referenced this pull requestOct 20, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.5.0
Development

Successfully merging this pull request may close these issues.

3 participants
@greglucas@timhoffm@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp