44*RGB* and *RGBA* are sequences of, respectively, 3 or 4 floats in the
55range 0-1.
66
7- This module includes functions and classes for color specification
8- conversions, and for mapping numbers to colors in a 1-D array of colors called
9- a colormap.
10-
11- Mapping data onto colors using a colormap typically involves two steps:
12- a data array is first mapped onto the range 0-1 using a subclass of
13- :class:`Normalize`, then this number is mapped to a color using
14- a subclass of :class:`Colormap`. Two are provided here:
15- :class:`LinearSegmentedColormap`, which uses piecewise-linear interpolation
16- to define colormaps, and :class:`ListedColormap`, which makes a colormap
17- from a list of colors.
7+ This module includes functions and classes for color specification conversions,
8+ and for mapping numbers to colors in a 1-D array of colors called a colormap.
9+
10+ Mapping data onto colors using a colormap typically involves two steps: a data
11+ array is first mapped onto the range 0-1 using a subclass of `Normalize`,
12+ then this number is mapped to a color using a subclass of `Colormap`. Two
13+ sublasses of `Colormap` provided here: `LinearSegmentedColormap`, which uses
14+ piecewise-linear interpolation to define colormaps, and `ListedColormap`, which
15+ makes a colormap from a list of colors.
1816
1917.. seealso::
2018
2927 More colormaps are available at palettable_.
3028
3129The module also provides functions for checking whether an object can be
32- interpreted as a color (:func: `is_color_like`), for converting such an object
33- to an RGBA tuple (:func: `to_rgba`) or to an HTML-like hex string in the
34- "#rrggbb" format (:func: `to_hex`), and a sequence of colors to an (n, 4)
35- RGBA array (:func: `to_rgba_array`). Caching is used for efficiency.
30+ interpreted as a color (`is_color_like`), for converting such an object
31+ to an RGBA tuple (`to_rgba`) or to an HTML-like hex string in the
32+ "#rrggbb" format (`to_hex`), and a sequence of colors to an (n, 4)
33+ RGBA array (`to_rgba_array`). Caching is used for efficiency.
3634
3735Matplotlib recognizes the following formats to specify a color:
3836
@@ -388,8 +386,8 @@ def _create_lookup_table(N, data, gamma=1.0):
388386 Parameters
389387 ----------
390388 N : int
391- The number of elements of the created lookup table.
392- This must be N >= 1.
389+ The number of elements of the created lookup table; at least 1 .
390+
393391 data : Mx3 array-like or callable
394392 Defines the mapping :math:`f`.
395393
@@ -415,6 +413,7 @@ def _create_lookup_table(N, data, gamma=1.0):
415413 data(x : ndarray) -> ndarray
416414
417415 and map values between 0 - 1 to 0 - 1.
416+
418417 gamma : float
419418 Gamma correction factor for input distribution x of the mapping.
420419
@@ -495,14 +494,14 @@ class Colormap:
495494 """
496495 Baseclass for all scalar to RGBA mappings.
497496
498- Typically Colormap instances are used to convert data values (floats) from
499- the interval ``[0, 1]`` to the RGBA color that the respective Colormap
500- represents. For scaling of data into the ``[0, 1]`` interval see
501- :class:`matplotlib.colors.Normalize`. It is worth noting that
502- :class:`matplotlib.cm.ScalarMappable` subclasses make heavy use of this
503- ``data->normalize->map-to-color`` processing chain.
504-
497+ Typically, Colormap instances are used to convert data values (floats)
498+ from the interval ``[0, 1]`` to the RGBA color that the respective
499+ Colormap represents. For scaling of data into the ``[0, 1]`` interval see
500+ `matplotlib.colors.Normalize`. Subclasses of `matplotlib.cm.ScalarMappable`
501+ make heavy use of this ``data -> normalize -> map-to-color`` processing
502+ chain.
505503 """
504+
506505 def __init__ (self , name , N = 256 ):
507506 """
508507 Parameters
@@ -511,7 +510,6 @@ def __init__(self, name, N=256):
511510 The name of the colormap.
512511 N : int
513512 The number of rgb quantization levels.
514-
515513 """
516514 self .name = name
517515 self .N = int (N ) # ensure that N is always int
@@ -522,11 +520,10 @@ def __init__(self, name, N=256):
522520 self ._i_over = self .N + 1
523521 self ._i_bad = self .N + 2
524522 self ._isinit = False
525-
526523 #: When this colormap exists on a scalar mappable and colorbar_extend
527524 #: is not False, colorbar creation will pick up ``colorbar_extend`` as
528525 #: the default value for the ``extend`` keyword in the
529- #: :class: `matplotlib.colorbar.Colorbar` constructor.
526+ #: `matplotlib.colorbar.Colorbar` constructor.
530527 self .colorbar_extend = False
531528
532529 def __call__ (self , X , alpha = None , bytes = False ):
@@ -1423,13 +1420,13 @@ def __init__(self, boundaries, ncolors, clip=False):
14231420 Number of colors in the colormap to be used
14241421 clip : bool, optional
14251422 If clip is ``True``, out of range values are mapped to 0 if they
1426- are below ``boundaries[0]`` or mapped to ncolors - 1 if they are
1427- above ``boundaries[-1]``.
1423+ are below ``boundaries[0]`` or mapped to `` ncolors - 1`` if they
1424+ are above ``boundaries[-1]``.
14281425
14291426 If clip is ``False``, out of range values are mapped to -1 if
1430- they are below ``boundaries[0]`` or mapped to ncolors if they are
1427+ they are below ``boundaries[0]`` or mapped to * ncolors* if they are
14311428 above ``boundaries[-1]``. These are then converted to valid indices
1432- by :meth: `Colormap.__call__`.
1429+ by `Colormap.__call__`.
14331430
14341431 Notes
14351432 -----
@@ -1648,11 +1645,11 @@ class LightSource:
16481645 Angles are in degrees, with the azimuth measured
16491646 clockwise from north and elevation up from the zero plane of the surface.
16501647
1651- The :meth:`shade` is used to produce "shaded" rgb values for a data array.
1652- :meth:`shade_rgb` can be used to combine an rgb image with
1653- The :meth:`shade_rgb`
1654- The :meth:`hillshade` produces an illumination map of a surface.
1648+ `shade` is used to produce "shaded" rgb values for a data array.
1649+ `shade_rgb` can be used to combine an rgb image with an elevation map.
1650+ `hillshade` produces an illumination map of a surface.
16551651 """
1652+
16561653 def __init__ (self , azdeg = 315 , altdeg = 45 , hsv_min_val = 0 , hsv_max_val = 1 ,
16571654 hsv_min_sat = 1 , hsv_max_sat = 0 ):
16581655 """
@@ -1674,8 +1671,8 @@ def __init__(self, azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1,
16741671 For backwards compatibility, the parameters *hsv_min_val*,
16751672 *hsv_max_val*, *hsv_min_sat*, and *hsv_max_sat* may be supplied at
16761673 initialization as well. However, these parameters will only be used if
1677- "blend_mode='hsv'" is passed into :meth: `shade` or :meth: `shade_rgb`.
1678- See the documentation for :meth: `blend_hsv` for more details.
1674+ "blend_mode='hsv'" is passed into `shade` or `shade_rgb`.
1675+ See the documentation for `blend_hsv` for more details.
16791676 """
16801677 self .azdeg = azdeg
16811678 self .altdeg = altdeg
@@ -2066,15 +2063,15 @@ def from_levels_and_colors(levels, colors, extend='neither'):
20662063 Parameters
20672064 ----------
20682065 levels : sequence of numbers
2069- The quantization levels used to construct the :class: `BoundaryNorm`.
2066+ The quantization levels used to construct the `BoundaryNorm`.
20702067 Value ``v`` is quantized to level ``i`` if ``lev[i] <= v < lev[i+1]``.
20712068 colors : sequence of colors
20722069 The fill color to use for each level. If *extend* is "neither" there
20732070 must be ``n_level - 1`` colors. For an *extend* of "min" or "max" add
20742071 one extra color, and for an *extend* of "both" add two colors.
20752072 extend : {'neither', 'min', 'max', 'both'}, optional
20762073 The behaviour when a value falls out of range of the given levels.
2077- See :func:`~matplotlib.pyplot .contourf` for details.
2074+ See `~.Axes .contourf` for details.
20782075
20792076 Returns
20802077 -------
0 commit comments