Skip to content

Commit c899614

Browse files
authored
Merge pull request #17903 from meeseeksmachine/auto-backport-of-pr-17859-on-v3.3.x
Backport PR #17859 on branch v3.3.x (API: resolve unset vmin / vmax in all ScalarMapple based methods)
2 parents c47b15d + 0cf73fd commit c899614

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

doc/api/prev_api_changes/api_changes_3.3.0/behaviour.rst

+30-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ internal quotes) now cause a ValueError to be raised.
9696
`.SymLogNorm` now has a *base* parameter
9797
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9898

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

104105

@@ -312,3 +313,29 @@ rcParam is True.
312313
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313314

314315
The *colors* parameter will now default to :rc:`lines.color`, while previously it defaulted to 'k'.
316+
317+
Aggressively autoscale clim in ``ScalerMappable`` classes
318+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319+
320+
321+
Previously some plotting methods would defer autoscaling until the
322+
first draw if only one of the *vmin* or *vmax* keyword arguments were
323+
passed (`.Axes.scatter`, `.Axes.hexbin`, `.Axes.imshow`,
324+
`.Axes.pcolorfast`) but would scale based on the passed data if
325+
neither was passed (independent of the *norm* keyword arguments).
326+
Other methods (`.Axes.pcolor`, `.Axes.pcolormesh`) always autoscaled
327+
base on the initial data.
328+
329+
All of the plotting methods now resolve the unset *vmin* or *vmax*
330+
at the initial call time using the data passed in.
331+
332+
If you were relying on exactly one of the *vmin* or *vmax* remaining
333+
unset between the time when the method is called and the first time
334+
the figure is rendered you get back the old behavior by manually setting
335+
the relevant limit back to `None` ::
336+
337+
cm_obj.norm.vmin = None
338+
# or
339+
cm_obj.norm.vmax = None
340+
341+
which will be resolved during the draw process.

lib/matplotlib/cm.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,10 @@ def _scale_norm(self, norm, vmin, vmax):
258258
"simultaneously is deprecated since %(since)s and "
259259
"will become an error %(removal)s. Please pass "
260260
"vmin/vmax directly to the norm when creating it.")
261-
else:
262-
self.autoscale_None()
261+
262+
# always resolve the autoscaling so we have concrete limits
263+
# rather than deferring to draw time.
264+
self.autoscale_None()
263265

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

0 commit comments

Comments
 (0)