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

AddsCenteredAsinhNorm class to automatically center asinh-normaliz…#30691

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

Open
U-C4N wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromU-C4N:main

Conversation

@U-C4N
Copy link

…ed data around a specified value (typically zero). This is useful for diverging colormaps where symmetric scaling is desired.

Users currently need to manually calculate and set symmetric vmin/vmax values when usingAsinhNorm with
diverging colormaps. This new class automates that process, similar to howCenteredNorm works for linear
scaling.

Changes

  • AddedCenteredAsinhNorm class inlib/matplotlib/colors.py
  • Added type stubs inlib/matplotlib/colors.pyi
  • Added 11 comprehensive test cases inlib/matplotlib/tests/test_colors.py
  • Fully documented with NumPy-style docstrings
  • Bilingual comments for maintainability

Closes#30679

…ed data around a specified value (typically zero). This is useful for diverging colormaps where symmetric scaling is desired.Users currently need to manually calculate and set symmetric vmin/vmax values when using `AsinhNorm` with  diverging colormaps. This new class automates that process, similar to how `CenteredNorm` works for linear  scaling.  ## Changes  - Added `CenteredAsinhNorm` class in `lib/matplotlib/colors.py`  -  Added type stubs in `lib/matplotlib/colors.pyi`  - Added 11 comprehensive test cases in `lib/matplotlib/tests/test_colors.py`  - Fully documented with NumPy-style docstrings  - Bilingual comments for maintainabilityClosesmatplotlib#30679
@timhoffm
Copy link
Member

Thanks for the contribution. Would we conceptually also need a CenteredSymLogNorm?
Im wondering whether we could get away without creating new classes. I suspect it needs to be a new class because the behavior wrt. to limits from data is different than for the uncentered variant (it's not just a prametrization change from vmin, vmax to vcenter, halfrange).

@U-C4N
Copy link
Author

Thanks for the contribution. Would we conceptually also need a CenteredSymLogNorm? Im wondering whether we could get away without creating new classes. I suspect it needs to be a new class because the behavior wrt. to limits from data is different than for the uncentered variant (it's not just a prametrization change from vmin, vmax to vcenter, halfrange).

Good question , but i think it could be useful for consistency but i do suggest we can start with CenteredAsinhNorm firstsince:

@sidneymau
Copy link

Catching up as I just saw this linked to the issue I raised.

Would we conceptually also need a CenteredSymLogNorm?
I had actually assumed thatSymLogNorm was centered (I haven't used it in a while), as it seems like you would always want that to be the case.

I agree that aCenteredSymLogNorm would be similarly useful, so really maybe this is suggesting that some way to consistently specify the center ofany norm would be beneficial. I'm just a user and haven't looked at the implementation in detail, but being able to specifycenter=0 onany norm would be a welcome feature (and would supersedeCentered* versions of each norm)

@timhoffm
Copy link
Member

While I would like to not build separate centered versions of the norms, we'd need to carefully think through behavior and API implications. Some incomplete

  • The standard way for auto scaling is to use min/max of the data. That's easy to change to expanding the smaller limit.
  • We may need to expose vcenter and halfrange properties, which is okish for AsinhNorm and SymlogNorm, as they have a natural center.
  • The verbose usage would be to pass the norm explicitly e.g.plt.imshow(values, SymLogNorm(...), where we have to encode the centering behavior and vcenter (default 0) through parameters.
  • The norm must internally store the centering state so that it can appropriately handle auto scaling.
  • A standard way of usage is via the norm name e.g.plt.imshow(values, norm="symlog"). We cannot encode any additional parameters here. However, one could map a special string like "centeredsymlog" to the special constructor.
  • Ranges can be predefined via the vmin, vmax kwargs:plt.imshow(values, norm="symlog", vmin=-1, vmax=1). This doesn't work for centered norms as we'd need other parameters vcenter, vrange. I'd be opposed opening this API for such alternative parametrizations. When using the norm name, this means we are limited to the defaults vcenter=0 and auto scaling. That may be good enough as it's the common case. If the user wants something else they'd need to pass an instance in - but that's no difference to a dedicated CenteredSymLog class.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[ENH]: A "CenteredAsinhNorm" would be useful

3 participants

@U-C4N@timhoffm@sidneymau

[8]ページ先頭

©2009-2025 Movatter.jp