Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 48126ca

Browse filesBrowse files
authored
Merge pull request #29461 from timhoffm/doc-mpltype-color
DOC: Use color specification reference in matplotlib.colors docs
2 parents 4943b99 + 6e155a9 commit 48126ca
Copy full SHA for 48126ca

File tree

1 file changed

+15
-11
lines changed
Filter options

1 file changed

+15
-11
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+15-11Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _is_nth_color(c):
221221

222222

223223
def is_color_like(c):
224-
"""Return whether *c* can be interpreted as an RGB(A) color."""
224+
"""Return whether *c* as a valid Matplotlib :mpltype:`color` specifier."""
225225
# Special-case nth color syntax because it cannot be parsed during setup.
226226
if _is_nth_color(c):
227227
return True
@@ -306,7 +306,7 @@ def to_rgba(c, alpha=None):
306306
307307
Parameters
308308
----------
309-
c : Matplotlib color or ``np.ma.masked``
309+
c : :mpltype:`color` or ``np.ma.masked``
310310
311311
alpha : float, optional
312312
If *alpha* is given, force the alpha value of the returned RGBA tuple
@@ -447,7 +447,7 @@ def to_rgba_array(c, alpha=None):
447447
448448
Parameters
449449
----------
450-
c : Matplotlib color or array of colors
450+
c : :mpltype:`color` or list of :mpltype:`color` or RGB(A) array
451451
If *c* is a masked array, an `~numpy.ndarray` is returned with a
452452
(0, 0, 0, 0) row for each masked value or row in *c*.
453453
@@ -550,7 +550,11 @@ def to_rgba_array(c, alpha=None):
550550

551551

552552
def to_rgb(c):
553-
"""Convert *c* to an RGB color, silently dropping the alpha channel."""
553+
"""
554+
Convert the :mpltype:`color` *c* to an RGB color tuple.
555+
556+
If c has an alpha channel value specified, that is silently dropped.
557+
"""
554558
return to_rgba(c)[:3]
555559

556560

@@ -560,7 +564,7 @@ def to_hex(c, keep_alpha=False):
560564
561565
Parameters
562566
----------
563-
c : :ref:`color <colors_def>` or `numpy.ma.masked`
567+
c : :mpltype:`color` or `numpy.ma.masked`
564568
565569
keep_alpha : bool, default: False
566570
If False, use the ``#rrggbb`` format, otherwise use ``#rrggbbaa``.
@@ -1198,7 +1202,7 @@ class ListedColormap(Colormap):
11981202
11991203
Parameters
12001204
----------
1201-
colors : list, array
1205+
colors : list of :mpltype:`color` or array
12021206
Sequence of Matplotlib color specifications (color names or RGB(A)
12031207
values).
12041208
name : str, optional
@@ -1857,12 +1861,12 @@ def with_extremes(self, *, bad=None, outside=None, shape=None, origin=None):
18571861
18581862
Parameters
18591863
----------
1860-
bad : None or :mpltype:`color`
1861-
If Matplotlib color, the *bad* value is set accordingly in the copy
1864+
bad : :mpltype:`color`, optional
1865+
If given, the *bad* value is set accordingly in the copy.
18621866
1863-
outside : None or :mpltype:`color`
1864-
If Matplotlib color and shape is 'ignore' or 'circleignore', values
1865-
*outside* the colormap are colored accordingly in the copy
1867+
outside : :mpltype:`color`, optional
1868+
If given and shape is 'ignore' or 'circleignore', values
1869+
*outside* the colormap are colored accordingly in the copy.
18661870
18671871
shape : {'square', 'circle', 'ignore', 'circleignore'}
18681872

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.