4
4
*RGB* and *RGBA* are sequences of, respectively, 3 or 4 floats in the
5
5
range 0-1.
6
6
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.
18
16
19
17
.. seealso::
20
18
29
27
More colormaps are available at palettable_.
30
28
31
29
The 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.
36
34
37
35
Matplotlib recognizes the following formats to specify a color:
38
36
@@ -388,8 +386,8 @@ def _create_lookup_table(N, data, gamma=1.0):
388
386
Parameters
389
387
----------
390
388
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
+
393
391
data : Mx3 array-like or callable
394
392
Defines the mapping :math:`f`.
395
393
@@ -415,6 +413,7 @@ def _create_lookup_table(N, data, gamma=1.0):
415
413
data(x : ndarray) -> ndarray
416
414
417
415
and map values between 0 - 1 to 0 - 1.
416
+
418
417
gamma : float
419
418
Gamma correction factor for input distribution x of the mapping.
420
419
@@ -495,14 +494,14 @@ class Colormap:
495
494
"""
496
495
Baseclass for all scalar to RGBA mappings.
497
496
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.
505
503
"""
504
+
506
505
def __init__ (self , name , N = 256 ):
507
506
"""
508
507
Parameters
@@ -511,7 +510,6 @@ def __init__(self, name, N=256):
511
510
The name of the colormap.
512
511
N : int
513
512
The number of rgb quantization levels.
514
-
515
513
"""
516
514
self .name = name
517
515
self .N = int (N ) # ensure that N is always int
@@ -522,11 +520,10 @@ def __init__(self, name, N=256):
522
520
self ._i_over = self .N + 1
523
521
self ._i_bad = self .N + 2
524
522
self ._isinit = False
525
-
526
523
#: When this colormap exists on a scalar mappable and colorbar_extend
527
524
#: is not False, colorbar creation will pick up ``colorbar_extend`` as
528
525
#: the default value for the ``extend`` keyword in the
529
- #: :class: `matplotlib.colorbar.Colorbar` constructor.
526
+ #: `matplotlib.colorbar.Colorbar` constructor.
530
527
self .colorbar_extend = False
531
528
532
529
def __call__ (self , X , alpha = None , bytes
2934
= False ):
@@ -1423,13 +1420,13 @@ def __init__(self, boundaries, ncolors, clip=False):
1423
1420
Number of colors in the colormap to be used
1424
1421
clip : bool, optional
1425
1422
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]``.
1428
1425
1429
1426
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
1431
1428
above ``boundaries[-1]``. These are then converted to valid indices
1432
- by :meth: `Colormap.__call__`.
1429
+ by `Colormap.__call__`.
1433
1430
1434
1431
Notes
1435
1432
-----
@@ -1648,11 +1645,11 @@ class LightSource:
1648
1645
Angles are in degrees, with the azimuth measured
1649
1646
clockwise from north and elevation up from the zero plane of the surface.
1650
1647
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.
1655
1651
"""
1652
+
1656
1653
def __init__ (self , azdeg = 315 , altdeg = 45 , hsv_min_val = 0 , hsv_max_val = 1 ,
1657
1654
hsv_min_sat = 1 , hsv_max_sat = 0 ):
1658
1655
"""
@@ -1674,8 +1671,8 @@ def __init__(self, azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1,
1674
1671
For backwards compatibility, the parameters *hsv_min_val*,
1675
1672
*hsv_max_val*, *hsv_min_sat*, and *hsv_max_sat* may be supplied at
1676
1673
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.
1679
1676
"""
1680
1677
self .azdeg = azdeg
1681
1678
self .altdeg = altdeg
@@ -2066,15 +2063,15 @@ def from_levels_and_colors(levels, colors, extend='neither'):
2066
2063
Parameters
2067
2064
----------
2068
2065
levels : sequence of numbers
2069
- The quantization levels used to construct the :class: `BoundaryNorm`.
2066
+ The quantization levels used to construct the `BoundaryNorm`.
2070
2067
Value ``v`` is quantized to level ``i`` if ``lev[i] <= v < lev[i+1]``.
2071
2068
colors : sequence of colors
2072
2069
The fill color to use for each level. If *extend* is "neither" there
2073
2070
must be ``n_level - 1`` colors. For an *extend* of "min" or "max" add
2074
2071
one extra color, and for an *extend* of "both" add two colors.
2075
2072
extend : {'neither', 'min', 'max', 'both'}, optional
2076
2073
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.
2078
2075
2079
2076
Returns
2080
2077
-------
0 commit comments