Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _is_nth_color(c):


def is_color_like(c):
"""Return whether *c* can be interpreted as an RGB(A) color."""
"""Return whether *c* as a valid Matplotlib :mpltype:`color` specifier."""
# Special-case nth color syntax because it cannot be parsed during setup.
if _is_nth_color(c):
return True
Expand Down Expand Up @@ -306,7 +306,7 @@ def to_rgba(c, alpha=None):

Parameters
----------
c : Matplotlib color or ``np.ma.masked``
c : :mpltype:`color` or ``np.ma.masked``

alpha : float, optional
If *alpha* is given, force the alpha value of the returned RGBA tuple
Expand Down Expand Up @@ -447,7 +447,7 @@ def to_rgba_array(c, alpha=None):

Parameters
----------
c : Matplotlib color or array of colors
c : :mpltype:`color` or list of :mpltype:`color` or RGB(A) array
If *c* is a masked array, an `~numpy.ndarray` is returned with a
(0, 0, 0, 0) row for each masked value or row in *c*.

Expand Down Expand Up @@ -550,7 +550,11 @@ def to_rgba_array(c, alpha=None):


def to_rgb(c):
"""Convert *c* to an RGB color, silently dropping the alpha channel."""
"""
Convert the :mpltype:`color` *c* to an RGB color tuple.

If c has an alpha channel value specified, that is silently dropped.
"""
return to_rgba(c)[:3]


Expand All @@ -560,7 +564,7 @@ def to_hex(c, keep_alpha=False):

Parameters
----------
c : :ref:`color <colors_def>` or `numpy.ma.masked`
c : :mpltype:`color` or `numpy.ma.masked`

keep_alpha : bool, default: False
If False, use the ``#rrggbb`` format, otherwise use ``#rrggbbaa``.
Expand Down Expand Up @@ -1198,7 +1202,7 @@ class ListedColormap(Colormap):

Parameters
----------
colors : list, array
colors : list of :mpltype:`color` or array
Sequence of Matplotlib color specifications (color names or RGB(A)
values).
name : str, optional
Expand Down Expand Up @@ -1857,12 +1861,12 @@ def with_extremes(self, *, bad=None, outside=None, shape=None, origin=None):

Parameters
----------
bad : None or :mpltype:`color`
If Matplotlib color, the *bad* value is set accordingly in the copy
bad : :mpltype:`color`, optional
If given, the *bad* value is set accordingly in the copy.

outside : None or :mpltype:`color`
If Matplotlib color and shape is 'ignore' or 'circleignore', values
*outside* the colormap are colored accordingly in the copy
outside : :mpltype:`color`, optional
If given and shape is 'ignore' or 'circleignore', values
*outside* the colormap are colored accordingly in the copy.

shape : {'square', 'circle', 'ignore', 'circleignore'}

Expand Down
Loading