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: Clarify/simplify example of multiple images with one colorbar#28546

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
timhoffm merged 2 commits intomatplotlib:mainfromtimhoffm:doc-multi-image
Jul 31, 2024

Conversation

timhoffm
Copy link
Member

@timhoffmtimhoffm commentedJul 12, 2024
edited
Loading

I've simplified the basic example to only share the norm. This should be sufficient for most users and greatly simplifies the code. Syncing the colorbar moved to a separate comment - for those wo need the extra functionality.

Copy link
Member

@story645story645 left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Wondering if this should just be a stand alone example (dynamic cmap updating? ) with same colormap tag b/c it's a lot of information that applies in a specific use case. ETA: got cut off, but was talking about:

# %%# The colors are now kept consistent across all images when changing the# scaling, e.g. through zooming in the colorbar or via the "edit axis,# curves and images parameters" GUI of the Qt backend.## While the norm is shared, the colormaps are not. This is often ok# because colormaps are usually not changed dynamically. However, a user# could change the colormap of an individual image through the# "edit axis, curves and images parameters" GUI of the Qt backend.# Unlike with a norm, it does not help to share colormaps between images.# Changes to the norm limits modify the norm object in place and thus# propagate to all images. But changing a colormap sets a new colormap# object to the images and thus does not propagate to the other images.# To make all other images follow, you could additionally sync the# colormaps using the following code::##     def sync_cmaps(changed_image):#         for im in images:#         if changed_image.get_cmap() != im.get_cmap():#             im.set_cmap(changed_image.get_cmap())##     for im in images:#         im.callbacks.connect('changed', sync_cmaps)

@timhoffm
Copy link
MemberAuthor

timhoffm commentedJul 13, 2024
edited
Loading

I believe that this is the right place to discuss cmap syncing.

  • The need for cmap syncing is quite rare because (1) you rarely change the colormap later. (2) I assume the Qt dialog is more or less the only way to change the colormap by an end-user without the possibility to intercept and handle this by the plot author (all other modifications likely have to go though some API provided by the author alongside the plot, which means they can be propagated actively to all images, without the need to monitor changes").
  • This is only meaningful as an extension to a shared norm. A separate example would have to completely include the code of this example first.
  • A seprate tile one the examples page does not help for visually finding the cmap syncing topic because you cannot illustrate cmap syncing in a static image.

I've made a subsection "Advanced: Additionally sync the colormap" to better set the context for this.

@timhoffm
Copy link
MemberAuthor

Ping@story645. What do you think of my suggestion?

Copy link
Member

@story645story645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

So uh I now understand better why you want to leave that here and I'm OK w/ that, but I went back and read through the explanations and uh I think they may have accidentally ended up in enough detail to spur questions but not enough to answer em territory :/

@timhoffmtimhoffmforce-pushed thedoc-multi-image branch 2 times, most recently fromf199fd4 toa425afbCompareJuly 29, 2024 10:26
Copy link
Member

@story645story645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is definitely much much better than before, thank you so much! Comments mostly around the same implementation detail problem, which is how do we effectively communicate that norm instances can be shared but not cmap instances.

Am thinking maybe (and I understand if this is out of scope and should be a follow up PR) we write this once as the final section ofchoosing colormaps. Call it "Using colormaps across multiple plots" , have this explanation, and use it as the lead in to "why norms" since that's the next topic, and then just link to that section here.

Comment on lines 14 to 16
to explicitly ensure consistent data coloring. The most important aspect
is the data normalization. By explicitly creating a norm and using that
for all images, we ensure that all images are scaled consistently.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
toexplicitlyensureconsistentdatacoloring.Themostimportantaspect
isthedatanormalization.Byexplicitlycreatinganormandusingthat
forallimages,weensurethatallimagesarescaledconsistently.
toexplicitlyensureconsistentdatacoloringbyusingthesamedatanormalization (datascaling)methodforalltheimages.Weensurethatsamemethodisusedbyexplicitlycreatinga*norm*objectthatwepasstoalltheimageplottingmethods.

Comment on lines +48 to +49
# curves and images parameters" GUI of the Qt backend. This is sufficient
# for most practical use cases.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
# curves and images parameters" GUI of the Qt backend. This is sufficient
# for most practical use cases.
# curves and images parameters" GUI of the Qt backend.

Folks will tell us if it's sufficient?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I see this as guidance and affirmation that most users can stop here. They don't have to inverst the following extra effort for cmap handling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hmm, maybe "this is" is just ambiguous pronoun reference then.

@timhoffm
Copy link
MemberAuthor

timhoffm commentedJul 30, 2024
edited
Loading

I've rewritten the paragraph on cmap sharing again. Focussing on the main point: Scaling changes the norm in place, but change of colormap changes the referenced colormap. Therefore sharing a colormap does not help and you need a different syncing mechanism.

Copy link
Member

@story645story645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Slight wording nits but this is really clear now, thanks! Take/leave nits and can self merge

Comment on lines +48 to +49
# curves and images parameters" GUI of the Qt backend. This is sufficient
# for most practical use cases.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hmm, maybe "this is" is just ambiguous pronoun reference then.

@timhoffmtimhoffm merged commitf7b3def intomatplotlib:mainJul 31, 2024
19 checks passed
@timhoffmtimhoffm deleted the doc-multi-image branchJuly 31, 2024 04:34
@QuLogicQuLogic added this to thev3.10.0 milestoneJul 31, 2024
@timhoffm
Copy link
MemberAuthor

@meeseeksdev backport to v.3.9.x

@timhoffm
Copy link
MemberAuthor

I'm backporting so that this version gets into released docs. It may be that this will be changed agian for 3.10 because of the upocomingColorizer changes. I want to make sure, this improved old-style method is kept publically available through 3.9 docs.

story645 reacted with thumbs up emoji

@lumberbot-appLumberbot (App)
Copy link

Something went wrong ... Please have a look at my logs.

It seems that the branch you are trying to backport to does not exist.

@timhoffm
Copy link
MemberAuthor

@meeseeksdev backport to v3.9.x

timhoffm added a commit that referenced this pull requestAug 5, 2024
…546-on-v3.9.xBackport PR#28546 on branch v3.9.x (DOC: Clarify/simplify example of multiple images with one colorbar)
@timhoffm
Copy link
MemberAuthor

@meeseeksdev backport to v3.9.1-doc

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestAug 5, 2024
timhoffm added a commit that referenced this pull requestAug 5, 2024
…546-on-v3.9.1-docBackport PR#28546 on branch v3.9.1-doc (DOC: Clarify/simplify example of multiple images with one colorbar)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@story645story645story645 approved these changes

Assignees
No one assigned
Labels
Documentation: examplesfiles in galleries/examples
Projects
None yet
Milestone
v3.10.0
Development

Successfully merging this pull request may close these issues.

3 participants
@timhoffm@story645@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp