Skip to content

Use :mpltype:color for color types #27557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions doc/sphinxext/custom_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ def mpltype_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
if mpltype not in type_to_link_target:
raise ValueError(f"Unknown mpltype: {mpltype!r}")

ref_nodes, messages = inliner.interpreted(
node_list, messages = inliner.interpreted(
mpltype, f'{mpltype} <{type_to_link_target[mpltype]}>', 'ref', lineno)
node_list = [ref_nodes]
return node_list, messages


Expand Down
38 changes: 19 additions & 19 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
`ax.transAxes`, i.e. the units of *rect* are in Axes-relative
coordinates.

facecolor : color, default: 'none'
facecolor : :mpltype:`color`, default: 'none'
Facecolor of the rectangle.

edgecolor : color, default: '0.5'
edgecolor : :mpltype:`color`, default: '0.5'
Color of the rectangle and color of the connecting lines.

alpha : float, default: 0.5
Expand Down Expand Up @@ -1073,7 +1073,7 @@ def hlines(self, y, xmin, xmax, colors=None, linestyles='solid',
Respective beginning and end of each line. If scalars are
provided, all lines will have the same length.

colors : color or list of colors, default: :rc:`lines.color`
colors : :mpltype:`color` or list of color , default: :rc:`lines.color`

linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, default: 'solid'

Expand Down Expand Up @@ -1164,7 +1164,7 @@ def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
Respective beginning and end of each line. If scalars are
provided, all lines will have the same length.

colors : color or list of colors, default: :rc:`lines.color`
colors : :mpltype:`color` or list of color, default: :rc:`lines.color`

linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, default: 'solid'

Expand Down Expand Up @@ -1300,7 +1300,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
If *positions* is 2D, this can be a sequence with length matching
the length of *positions*.

colors : color or list of colors, default: :rc:`lines.color`
colors : :mpltype:`color` or list of color, default: :rc:`lines.color`
The color(s) of the event lines.

If *positions* is 2D, this can be a sequence with length matching
Expand Down Expand Up @@ -2333,10 +2333,10 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",

Other Parameters
----------------
color : color or list of color, optional
color : :mpltype:`color` or list of :mpltype:`color`, optional
The colors of the bar faces.

edgecolor : color or list of color, optional
edgecolor : :mpltype:`color` or list of :mpltype:`color`, optional
The colors of the bar edges.

linewidth : float or array-like, optional
Expand Down Expand Up @@ -2368,7 +2368,7 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
See :doc:`/gallery/statistics/errorbar_features` for an example on
the usage of *xerr* and *yerr*.

ecolor : color or list of color, default: 'black'
ecolor : :mpltype:`color` or list of :mpltype:`color`, default: 'black'
The line color of the errorbars.

capsize : float, default: :rc:`errorbar.capsize`
Expand Down Expand Up @@ -2646,10 +2646,10 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",

Other Parameters
----------------
color : color or list of color, optional
color : :mpltype:`color` or list of :mpltype:`color`, optional
The colors of the bar faces.

edgecolor : color or list of color, optional
edgecolor : :mpltype:`color` or list of :mpltype:`color`, optional
The colors of the bar edges.

linewidth : float or array-like, optional
Expand Down Expand Up @@ -2681,7 +2681,7 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
See :doc:`/gallery/statistics/errorbar_features` for an example on
the usage of *xerr* and *yerr*.

ecolor : color or list of color, default: 'black'
ecolor : :mpltype:`color` or list of :mpltype:`color`, default: 'black'
The line color of the errorbars.

capsize : float, default: :rc:`errorbar.capsize`
Expand Down Expand Up @@ -3139,7 +3139,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
labels : list, default: None
A sequence of strings providing the labels for each wedge

colors : color or array-like of color, default: None
colors : :mpltype:`color` or list of :mpltype:`color`, default: None
A sequence of colors through which the pie chart will cycle. If
*None*, will use the colors in the currently active cycle.

Expand Down Expand Up @@ -3434,7 +3434,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
Use 'none' (case-insensitive) to plot errorbars without any data
markers.

ecolor : color, default: None
ecolor : :mpltype:`color`, default: None
The color of the errorbar lines. If None, use the color of the
line connecting the markers.

Expand Down Expand Up @@ -4416,9 +4416,9 @@ def _parse_scatter_color_args(c, edgecolors, kwargs, xsize,

Parameters
----------
c : color or sequence or sequence of color or None
c : :mpltype:`color` or array-like or list of :mpltype:`color` or None
See argument description of `.Axes.scatter`.
edgecolors : color or sequence of color or {'face', 'none'} or None
edgecolors : :mpltype:`color` or sequence of color or {'face', 'none'} or None
See argument description of `.Axes.scatter`.
kwargs : dict
Additional kwargs. If these keys exist, we pop and process them:
Expand Down Expand Up @@ -4575,7 +4575,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
To eliminate the marker edge either set *linewidth=0* or
*edgecolor='none'*.

c : array-like or list of colors or color, optional
c : array-like or list of :mpltype:`color` or :mpltype:`color`, optional
The marker colors. Possible values:

- A scalar or sequence of n numbers to be mapped to colors using
Expand Down Expand Up @@ -4625,8 +4625,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
The linewidth of the marker edges. Note: The default *edgecolors*
is 'face'. You may want to change this as well.

edgecolors : {'face', 'none', *None*} or color or sequence of color, \
default: :rc:`scatter.edgecolors`
edgecolors : {'face', 'none', *None*} or :mpltype:`color` or list of \
:mpltype:`color`, default: :rc:`scatter.edgecolors`
The edge color of the marker. Possible values:

- 'face': The edge color will always be the same as the face color.
Expand Down Expand Up @@ -6738,7 +6738,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
log : bool, default: False
If ``True``, the histogram axis will be set to a log scale.

color : color or array-like of colors or None, default: None
color : :mpltype:`color` or list of :mpltype:`color` or None, default: None
Color or sequence of colors, one per dataset. Default (``None``)
uses the standard line color sequence.

Expand Down
10 changes: 5 additions & 5 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ def set_facecolor(self, color):

Parameters
----------
color : color; see :ref:`colors_def`
color : :mpltype:`color`
"""
self._facecolor = color
self.stale = True
Expand Down Expand Up @@ -3379,17 +3379,17 @@ def tick_params(self, axis='both', **kwargs):
Tick length in points.
width : float
Tick width in points.
color : color
color : :mpltype:`color`
Tick color.
pad : float
Distance in points between tick and label.
labelsize : float or str
Tick label font size in points or as a string (e.g., 'large').
labelcolor : color
labelcolor : :mpltype:`color`
Tick label color.
labelfontfamily : str
Tick label font.
colors : color
colors : :mpltype:`color`
Tick color and label color.
zorder : float
Tick and label zorder.
Expand All @@ -3399,7 +3399,7 @@ def tick_params(self, axis='both', **kwargs):
Whether to draw the respective tick labels.
labelrotation : float
Tick label rotation
grid_color : color
grid_color : :mpltype:`color`
Gridline color.
grid_alpha : float
Transparency of gridlines: 0 (transparent) to 1 (opaque).
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_secondary_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def set_color(self, color):

Parameters
----------
color : color; see :ref:`colors_def`
color : :mpltype:`color`
"""
axis = self._axis_map[self._orientation]
axis.set_tick_params(colors=color)
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path,
The locations to draw the markers.
trans : `~matplotlib.transforms.Transform`
An affine transform applied to the path.
rgbFace : color, optional
rgbFace : :mpltype:`color`, optional
"""
for vertices, codes in path.iter_segments(trans, simplify=False):
if len(vertices):
Expand Down Expand Up @@ -956,7 +956,7 @@ def set_foreground(self, fg, isRGBA=False):

Parameters
----------
fg : color
fg : :mpltype:`color`
isRGBA : bool
If *fg* is known to be an ``(r, g, b, a)`` tuple, *isRGBA* can be
set to True to improve performance.
Expand Down Expand Up @@ -2111,11 +2111,11 @@ def print_figure(
dpi : float, default: :rc:`savefig.dpi`
The dots per inch to save the figure in.

facecolor : color or 'auto', default: :rc:`savefig.facecolor`
facecolor : :mpltype:`color` or 'auto', default: :rc:`savefig.facecolor`
The facecolor of the figure. If 'auto', use the current figure
facecolor.

edgecolor : color or 'auto', default: :rc:`savefig.edgecolor`
edgecolor : :mpltype:`color` or 'auto', default: :rc:`savefig.edgecolor`
The edgecolor of the figure. If 'auto', use the current figure
edgecolor.

Expand Down
20 changes: 10 additions & 10 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ def __init__(self, *,
"""
Parameters
----------
edgecolors : color or list of colors, default: :rc:`patch.edgecolor`
edgecolors : :mpltype:`color` or list of colors, default: :rc:`patch.edgecolor`
Edge color for each patch making up the collection. The special
value 'face' can be passed to make the edgecolor match the
facecolor.
facecolors : color or list of colors, default: :rc:`patch.facecolor`
facecolors : :mpltype:`color` or list of colors, default: :rc:`patch.facecolor`
Face color for each patch making up the collection.
linewidths : float or list of floats, default: :rc:`patch.linewidth`
Line width for each patch making up the collection.
Expand Down Expand Up @@ -745,7 +745,7 @@ def set_color(self, c):

Parameters
----------
c : color or list of RGBA tuples
c : :mpltype:`color` or list of RGBA tuples

See Also
--------
Expand Down Expand Up @@ -776,7 +776,7 @@ def set_facecolor(self, c):

Parameters
----------
c : color or list of colors
c : :mpltype:`color` or list of :mpltype:`color`
"""
if isinstance(c, str) and c.lower() in ("none", "face"):
c = c.lower()
Expand Down Expand Up @@ -821,7 +821,7 @@ def set_edgecolor(self, c):

Parameters
----------
c : color or list of colors or 'face'
c : :mpltype:`color` or list of :mpltype:`color` or 'face'
The collection edgecolor(s). If a sequence, the patches cycle
through it. If 'face', match the facecolor.
"""
Expand Down Expand Up @@ -1368,15 +1368,15 @@ def __init__(self, segments, # Can be None.
can have a different number of segments.
linewidths : float or list of float, default: :rc:`lines.linewidth`
The width of each line in points.
colors : color or list of color, default: :rc:`lines.color`
colors : :mpltype:`color` or list of color, default: :rc:`lines.color`
A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not
allowed).
antialiaseds : bool or list of bool, default: :rc:`lines.antialiased`
Whether to use antialiasing for each line.
zorder : float, default: 2
zorder of the lines once drawn.

facecolors : color or list of color, default: 'none'
facecolors : :mpltype:`color` or list of :mpltype:`color`, default: 'none'
When setting *facecolors*, each line is interpreted as a boundary
for an area, implicitly closing the path from the last point to the
first point. The enclosed area is filled with *facecolor*.
Expand Down Expand Up @@ -1455,7 +1455,7 @@ def set_color(self, c):

Parameters
----------
c : color or list of colors
c : :mpltype:`color` or list of :mpltype:`color`
Single color (all lines have same color), or a
sequence of RGBA tuples; if it is a sequence the lines will
cycle through the sequence.
Expand Down Expand Up @@ -1483,7 +1483,7 @@ def set_gapcolor(self, gapcolor):

Parameters
----------
gapcolor : color or list of colors or None
gapcolor : :mpltype:`color` or list of :mpltype:`color` or None
The color with which to fill the gaps. If None, the gaps are
unfilled.
"""
Expand Down Expand Up @@ -1556,7 +1556,7 @@ def __init__(self,
``lineoffset - linelength/2`` to ``lineoffset + linelength/2``).
linewidth : float or list thereof, default: :rc:`lines.linewidth`
The line width of the event lines, in points.
color : color or list of colors, default: :rc:`lines.color`
color : :mpltype:`color` or list of :mpltype:`color`, default: :rc:`lines.color`
The color of the event lines.
linestyle : str or tuple or list thereof, default: 'solid'
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted',
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ def add_lines(self, *args, **kwargs):
----------
levels : array-like
The positions of the lines.
colors : color or list of colors
colors : :mpltype:`color` or list of :mpltype:`color`
Either a single color applying to all lines or one color value for
each line.
linewidths : float or array-like
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def register(self, name, color_list):
name : str
The name for the color sequence.

color_list : list of colors
color_list : list of :mpltype:`color`
An iterable returning valid Matplotlib colors when iterating over.
Note however that the returned color sequence will always be a
list regardless of the input type.
Expand Down Expand Up @@ -1042,7 +1042,7 @@ def from_list(name, colors, N=256, gamma=1.0):
----------
name : str
The name of the colormap.
colors : array-like of colors or array-like of (value, color)
colors : list of :mpltype:`color` or list of (value, color)
If only colors are given, they are equidistantly mapped from the
range :math:`[0, 1]`; i.e. 0 maps to ``colors[0]`` and 1 maps to
``colors[-1]``.
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def clabel(self, levels=None, *,
Size in points or relative size e.g., 'smaller', 'x-large'.
See `.Text.set_size` for accepted string values.

colors : color or colors or None, default: None
colors : :mpltype:`color` or colors or None, default: None
The label colors:

- If *None*, the color of each label matches the color of
Expand Down Expand Up @@ -1653,7 +1653,7 @@ def _initialize_x_y(self, z):
nearest those points are always masked out, other triangular
corners comprising three unmasked points are contoured as usual.

colors : color string or sequence of colors, optional
colors : :mpltype:`color` or list of :mpltype:`color`, optional
The colors of the levels, i.e. the lines for `.contour` and the
areas for `.contourf`.

Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def set_edgecolor(self, color):

Parameters
----------
color : color; see :ref:`colors_def`
color : :mpltype:`color`
"""
self.patch.set_edgecolor(color)

Expand All @@ -407,7 +407,7 @@ def set_facecolor(self, color):

Parameters
----------
color : color; see :ref:`colors_def`
color : :mpltype:`color`
"""
self.patch.set_facecolor(color)

Expand Down Expand Up @@ -3261,11 +3261,11 @@ def savefig(self, fname, *, transparent=None, **kwargs):
compressed layout engine; ignored if one of those engines is not in
use.

facecolor : color or 'auto', default: :rc:`savefig.facecolor`
facecolor : :mpltype:`color` or 'auto', default: :rc:`savefig.facecolor`
The facecolor of the figure. If 'auto', use the current figure
facecolor.

edgecolor : color or 'auto', default: :rc:`savefig.edgecolor`
edgecolor : :mpltype:`color` or 'auto', default: :rc:`savefig.edgecolor`
The edgecolor of the figure. If 'auto', use the current figure
edgecolor.

Expand Down
Loading