Skip to content

Backport PR #17859 on branch v3.3.x (API: resolve unset vmin / vmax in all ScalarMapple based methods) #17903

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions doc/api/prev_api_changes/api_changes_3.3.0/behaviour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ internal quotes) now cause a ValueError to be raised.
`.SymLogNorm` now has a *base* parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, `.SymLogNorm` had no *base* kwarg, and defaulted to ``base=np.e``
whereas the documentation said it was ``base=10``. In preparation to make
the default 10, calling `.SymLogNorm` without the new *base* kwarg emits a
Previously, `.SymLogNorm` had no *base* keyword argument, and
defaulted to ``base=np.e`` whereas the documentation said it was
``base=10``. In preparation to make the default 10, calling
`.SymLogNorm` without the new *base* keyword argument emits a
deprecation warning.


Expand Down Expand Up @@ -312,3 +313,29 @@ rcParam is True.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The *colors* parameter will now default to :rc:`lines.color`, while previously it defaulted to 'k'.

Aggressively autoscale clim in ``ScalerMappable`` classes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Previously some plotting methods would defer autoscaling until the
first draw if only one of the *vmin* or *vmax* keyword arguments were
passed (`.Axes.scatter`, `.Axes.hexbin`, `.Axes.imshow`,
`.Axes.pcolorfast`) but would scale based on the passed data if
neither was passed (independent of the *norm* keyword arguments).
Other methods (`.Axes.pcolor`, `.Axes.pcolormesh`) always autoscaled
base on the initial data.

All of the plotting methods now resolve the unset *vmin* or *vmax*
at the initial call time using the data passed in.

If you were relying on exactly one of the *vmin* or *vmax* remaining
unset between the time when the method is called and the first time
the figure is rendered you get back the old behavior by manually setting
the relevant limit back to `None` ::

cm_obj.norm.vmin = None
# or
cm_obj.norm.vmax = None

which will be resolved during the draw process.
6 changes: 4 additions & 2 deletions lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,10 @@ def _scale_norm(self, norm, vmin, vmax):
"simultaneously is deprecated since %(since)s and "
"will become an error %(removal)s. Please pass "
"vmin/vmax directly to the norm when creating it.")
else:
self.autoscale_None()

# always resolve the autoscaling so we have concrete limits
# rather than deferring to draw time.
self.autoscale_None()

def to_rgba(self, x, alpha=None, bytes=False, norm=True):
"""
Expand Down