Skip to content

Commit 7f71233

Browse files
committed
Merge pull request #3628 from switham/master
DOC : Document auto-init behavior of colors.Normalize and cm.ScalarMappable.
2 parents 83062f8 + 1f07ab1 commit 7f71233

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/matplotlib/cm.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,10 @@ def __init__(self, norm=None, cmap=None):
178178
norm : :class:`matplotlib.colors.Normalize` instance
179179
The normalizing object which scales data, typically into the
180180
interval ``[0, 1]``.
181+
If *None*, *norm* defaults to a *colors.Normalize* object which
182+
initializes its scaling based on the first data processed.
181183
cmap : str or :class:`~matplotlib.colors.Colormap` instance
182184
The colormap used to map normalized data values to RGBA colors.
183-
184185
"""
185186

186187
self.callbacksSM = cbook.CallbackRegistry()

lib/matplotlib/colors.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -851,10 +851,12 @@ class Normalize(object):
851851
"""
852852
def __init__(self, vmin=None, vmax=None, clip=False):
853853
"""
854-
If *vmin* or *vmax* is not given, they are taken from the input's
855-
minimum and maximum value respectively. If *clip* is *True* and
856-
the given value falls outside the range, the returned value
857-
will be 0 or 1, whichever is closer. Returns 0 if::
854+
If *vmin* or *vmax* is not given, they are initialized from the
855+
minimum and maximum value respectively of the first input
856+
processed. That is, *__call__(A)* calls *autoscale_None(A)*.
857+
If *clip* is *True* and the given value falls outside the range,
858+
the returned value will be 0 or 1, whichever is closer.
859+
Returns 0 if::
858860
859861
vmin==vmax
860862
@@ -902,6 +904,13 @@ def process_value(value):
902904
return result, is_scalar
903905

904906
def __call__(self, value, clip=None):
907+
"""
908+
Normalize *value* data in the ``[vmin, vmax]`` interval into
909+
the ``[0.0, 1.0]`` interval and return it. *clip* defaults
910+
to *self.clip* (which defaults to *False*). If not already
911+
initialized, *vmin* and *vmax* are initialized using
912+
*autoscale_None(value)*.
913+
"""
905914
if clip is None:
906915
clip = self.clip
907916

0 commit comments

Comments
 (0)