@@ -140,18 +140,7 @@ def is_color_like(c):
140140
141141
142142def same_color (c1 , c2 ):
143- """
144- Compare two colors to see if they are the same.
145-
146- Parameters
147- ----------
148- c1, c2 : Matplotlib colors
149-
150- Returns
151- -------
152- bool
153- ``True`` if *c1* and *c2* are the same color, otherwise ``False``.
154- """
143+ """Return whether the colors *c1* and *c2* are the same."""
155144 return (to_rgba_array (c1 ) == to_rgba_array (c2 )).all ()
156145
157146
@@ -192,7 +181,8 @@ def to_rgba(c, alpha=None):
192181
193182
194183def _to_rgba_no_colorcycle (c , alpha = None ):
195- """Convert *c* to an RGBA color, with no support for color-cycle syntax.
184+ """
185+ Convert *c* to an RGBA color, with no support for color-cycle syntax.
196186
197187 If *alpha* is not ``None``, it forces the alpha value, except if *c* is
198188 ``"none"`` (case-insensitive), which always maps to ``(0, 0, 0, 0)``.
@@ -281,7 +271,8 @@ def _to_rgba_no_colorcycle(c, alpha=None):
281271
282272
283273def to_rgba_array (c , alpha = None ):
284- """Convert *c* to a (n, 4) array of RGBA colors.
274+ """
275+ Convert *c* to a (n, 4) array of RGBA colors.
285276
286277 If *alpha* is not ``None``, it forces the alpha value. If *c* is
287278 ``"none"`` (case-insensitive) or an empty list, an empty array is returned.
@@ -388,7 +379,8 @@ class ColorConverter:
388379
389380
390381def _create_lookup_table (N , data , gamma = 1.0 ):
391- r"""Create an *N* -element 1-d lookup table.
382+ r"""
383+ Create an *N* -element 1-d lookup table.
392384
393385 This assumes a mapping :math:`f : [0, 1] \rightarrow [0, 1]`. The returned
394386 data is an array of N values :math:`y = f(x)` where x is sampled from
@@ -602,8 +594,6 @@ def __call__(self, X, alpha=None, bytes=False):
602594 return rgba
603595
604596 def __copy__ (self ):
605- """Create new object with the same class, update attributes
606- """
607597 cls = self .__class__
608598 cmapobject = cls .__new__ (cls )
609599 cmapobject .__dict__ .update (self .__dict__ )
@@ -612,8 +602,7 @@ def __copy__(self):
612602 return cmapobject
613603
614604 def set_bad (self , color = 'k' , alpha = None ):
615- """Set color to be used for masked values.
616- """
605+ """Set the color for masked values."""
617606 self ._rgba_bad = to_rgba (color , alpha )
618607 if self ._isinit :
619608 self ._set_extremes ()
@@ -656,16 +645,14 @@ def is_gray(self):
656645 np .all (self ._lut [:, 0 ] == self ._lut [:, 2 ]))
657646
658647 def _resample (self , lutsize ):
659- """
660- Return a new color map with *lutsize* entries.
661- """
648+ """Return a new color map with *lutsize* entries."""
662649 raise NotImplementedError ()
663650
664651 def reversed (self , name = None ):
665652 """
666- Make a reversed instance of the Colormap.
653+ Return a reversed instance of the Colormap.
667654
668- .. note:: Function not implemented for base class.
655+ .. note:: This function is not implemented for base class.
669656
670657 Parameters
671658 ----------
@@ -758,23 +745,29 @@ def _init(self):
758745 self ._set_extremes ()
759746
760747 def set_gamma (self , gamma ):
761- """
762- Set a new gamma value and regenerate color map.
763- """
748+ """Set a new gamma value and regenerate color map."""
764749 self ._gamma = gamma
765750 self ._init ()
766751
767752 @staticmethod
768753 def from_list (name , colors , N = 256 , gamma = 1.0 ):
769754 """
770- Make a linear segmented colormap with *name* from a sequence
771- of *colors* which evenly transitions from colors[0] at val=0
772- to colors[-1] at val=1. *N* is the number of rgb quantization
773- levels.
774- Alternatively, a list of (value, color) tuples can be given
775- to divide the range unevenly.
776- """
755+ Create a `LinearSegmentedColormap` from a list of colors.
777756
757+ Parameters
758+ ----------
759+ name : str
760+ The name of the colormap.
761+ colors : array-like of colors or array-like of (value, color)
762+ If only colors are given, they are equidistantly mapped from the
763+ range :math:`[0, 1]`; i.e. 0 maps to ``colors[0]`` and 1 maps to
764+ ``colors[-1]``.
765+ If (value, color) pairs are given, the mapping is from *value*
766+ to *color*. This can be used to divide the range unevenly.
767+ N : int
768+ The number of rgb quantization levels.
769+ gamma : float
770+ """
778771 if not np .iterable (colors ):
779772 raise ValueError ('colors must be iterable' )
780773
@@ -796,9 +789,7 @@ def from_list(name, colors, N=256, gamma=1.0):
796789 return LinearSegmentedColormap (name , cdict , N , gamma )
797790
798791 def _resample (self , lutsize ):
799- """
800- Return a new color map with *lutsize* entries.
801- """
792+ """Return a new color map with *lutsize* entries."""
802793 return LinearSegmentedColormap (self .name , self ._segmentdata , lutsize )
803794
804795 # Helper ensuring picklability of the reversed cmap.
@@ -808,7 +799,7 @@ def _reverser(func, x):
808799
809800 def reversed (self , name = None ):
810801 """
811- Make a reversed instance of the Colormap.
802+ Return a reversed instance of the Colormap.
812803
813804 Parameters
814805 ----------
@@ -892,15 +883,13 @@ def _init(self):
892883 self ._set_extremes ()
893884
894885 def _resample (self , lutsize ):
895- """
896- Return a new color map with *lutsize* entries.
897- """
886+ """Return a new color map with *lutsize* entries."""
898887 colors = self (np .linspace (0 , 1 , lutsize ))
899888 return ListedColormap (colors , name = self .name )
900889
901890 def reversed (self , name = None ):
902891 """
903- Make a reversed instance of the Colormap.
892+ Return a reversed instance of the Colormap.
904893
905894 Parameters
906895 ----------
@@ -929,8 +918,8 @@ def __init__(self, vmin=None, vmax=None, clip=False):
929918 """
930919 Parameters
931920 ----------
932- vmin : scalar
933- vmax : scalar
921+ vmin : float
922+ vmax : float
934923 clip : bool
935924 If ``True`` values falling outside the range ``[vmin, vmax]``,
936925 are mapped to 0 or 1, whichever is closer, and masked values are
0 commit comments