Skip to content

Commit 94f9032

Browse files
committed
Actions by @NelleV.
1 parent afa1cfc commit 94f9032

File tree

5 files changed

+28
-21
lines changed

5 files changed

+28
-21
lines changed

doc/api/colors_api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
colors
33
******
44

5-
For a plot showing the available matplotlib colormaps see the
6-
:ref:`colormap <pylab_examples-show_colormaps>` example.
5+
For a visual representation of the matplotlib colormaps, see the
6+
"Color" section in the gallery.
77

88

99
:mod:`matplotlib.colors`

doc/api/matplotlib_configuration_api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ The top level :mod:`matplotlib` module
22
======================================
33

44
.. automodule:: matplotlib
5-
:members: rc, rcdefaults, use
65
:members:
76
:undoc-members:
87
:show-inheritance:
File renamed without changes.

lib/matplotlib/cm.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,22 @@ def get_cmap(name=None, lut=None):
163163

164164
class ScalarMappable:
165165
"""
166-
This is a mixin class to support scalar -> RGBA mapping. Handles
167-
normalization and colormapping
168-
"""
166+
This is a mixin class to support scalar data to RGBA mapping.
167+
The ScalarMappable makes use of data normalization before returning
168+
RGBA colors from the given colormap.
169169
170+
"""
170171
def __init__(self, norm=None, cmap=None):
171-
"""
172-
*norm* is an instance of :class:`matplotlib.colors.Normalize` or
173-
one of its subclasses, used to map luminance to 0-1. *cmap* is a
174-
:mod:`~matplotlib.cm.Colormap` instance, for example
175-
:data:`matplotlib.cm.jet`.
172+
r"""
173+
174+
Parameters
175+
----------
176+
norm : :class:`matplotlib.colors.Normalize` instance
177+
The normalizing object which scales data, typically into the
178+
interval ``[0, 1]``.
179+
cmap : str or :class:`~matplotlib.colors.Colormap` instance
180+
The colormap used to map normalized data values to RGBA colors.
181+
176182
"""
177183

178184
self.callbacksSM = cbook.CallbackRegistry()
@@ -182,8 +188,10 @@ def __init__(self, norm=None, cmap=None):
182188
if norm is None:
183189
norm = colors.Normalize()
184190

185-
self._A = None
191+
self._A = None;
192+
#; The Normalization instance of this ScalarMappable.
186193
self.norm = norm
194+
#; The Colormap instance of this ScalarMappable.
187195
self.cmap = get_cmap(cmap)
188196
self.colorbar = None
189197
self.update_dict = {'array': False}

lib/matplotlib/colors.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,15 @@ class Colormap(object):
483483
Typically Colormap instances are used to convert data values (floats) from
484484
the interval ``[0, 1]`` to the RGBA color that the respective Colormap
485485
represents. For scaling of data into the ``[0, 1]`` interval see
486-
:class:`matplotlib.colors.Normalize`.
486+
:class:`matplotlib.colors.Normalize`. It is worth noting that
487+
:class:`matplotlib.cm.ScalarMappable` subclasses make heavy use of this
488+
``data->normalize->map-to-color`` processing chain.
487489
488490
"""
489491
def __init__(self, name, N=256):
490-
"""
492+
r"""
491493
Parameters
492-
494+
----------
493495
name : str
494496
The name of the colormap.
495497
N : int
@@ -508,25 +510,23 @@ def __init__(self, name, N=256):
508510

509511
def __call__(self, X, alpha=None, bytes=False):
510512
"""
511-
Parameters:
512-
513+
Parameters
514+
----------
513515
X : scalar, ndarray
514516
The data value(s) to convert to RGBA.
515517
For floats, X should be in the interval ``[0.0, 1.0]`` to
516518
return the RGBA values ``X*100`` percent along the Colormap line.
517519
For integers, X should be in the interval ``[0, Colormap.N)`` to
518520
return RGBA values *indexed* from the Colormap with index ``X``.
519-
520521
alpha : float, None
521522
Alpha must be a scalar between 0 and 1, or None.
522-
523523
bytes : bool
524524
If False (default), the returned RGBA values will be floats in the
525525
interval ``[0, 1]`` otherwise they will be uint8s in the interval
526526
``[0, 255]``.
527527
528-
Returns:
529-
528+
Returns
529+
-------
530530
Tuple of RGBA values if X is scalar, othewise an array of
531531
RGBA values with a shape of ``X.shape + (4, )``.
532532

0 commit comments

Comments
 (0)