Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6286e1d

Browse files
committed
API: resolve unset vmin / vmax in all ScalarMapple based methods
closes #17703
1 parent bdf0177 commit 6286e1d

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,30 @@ rcParam is True.
312312
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313313

314314
The *colors* parameter will now default to :rc:`lines.color`, while previously it defaulted to 'k'.
315+
316+
Aggressively autoscale clim in ``ScalerMappable`` classes
317+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318+
319+
320+
Previously some plotting methods would defer autoscaling until the
321+
first draw if only one of the *vmin* or *vmax* keyword arguments was
322+
passed (`.Axes.scatter`, `.Axes.hexbin`, `.Axes.imshow`,
323+
`.Axes.pcolorfast`) but would scale based on the passed data if
324+
neither was passed (independent if the *norm* kwarg).
325+
326+
Other methods (`.Axes.pcolor`, `.Axes.pcolormesh`)
327+
always autoscaled base on the initial data.
328+
329+
All of the plotting methods now resolve, based on the passed data, the
330+
the unset *vmin* or *vmax* at init time based on the data passed.
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 at during the draw process.

lib/matplotlib/cm.py

Lines changed: 4 additions & 2 deletions
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)