Skip to content

Added PowerScale similar to LogScale as per 20355 #2

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Sreekanth-M8
Copy link

PR summary

Added PowerScale PowerTransform InversePowerTransform to scale.py
Changed PowerNorm and made it similar to LogNorm in colors.py

PR checklist

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@r3kste r3kste self-requested a review July 28, 2025 10:35
Copy link
Owner

@r3kste r3kste left a comment

Choose a reason for hiding this comment

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

There are a few additional things we need to address before going forward. I have left some remarks.

In addition to this, you need to add 'power': PowerScale to the _scale_mapping dictionary in scale.py so that PowerScale is registered.

return self._transform

def set_default_locators_and_formatters(self, axis):
axis.set_major_locator(AutoLocator())
Copy link
Owner

Choose a reason for hiding this comment

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

Other scales use their own custom locator so I don't think AutoLocator is supposed to be used here. I think we would probably have to define a new tick locator PowerLocator to be used here.

PowerNorm = make_norm_from_scale(
functools.partial(scale.PowerScale))(Normalize)
PowerNorm.__name__ = PowerNorm.__qualname__ = "PowerNorm"
PowerNorm.__doc__ = "Normalize a given value to the 0-1 range using a power-law scale."
Copy link
Owner

Choose a reason for hiding this comment

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

Is there any reason to define PowerNorm like this. I see that only LogNorm uses this kind of definition, while all other norms define a class like this:

@make_norm_from_scale(
    scale.FuncScale,
    init=lambda functions, vmin=None, vmax=None, clip=False: None)
class FuncNorm(Normalize):
    """
    Arbitrary normalization using functions for the forward and inverse.

It would be better if we do what other norms follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants