Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33498df

Browse files
committed
DOCS: use "or list thereof" for collection types
1 parent 42ee10f commit 33498df

File tree

1 file changed

+44
-41
lines changed

1 file changed

+44
-41
lines changed

lib/matplotlib/collections.py

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,17 @@ def __init__(self,
9393
**kwargs
9494
):
9595
"""
96-
For all "plural" parameters, the type listed is the expected type when
97-
passing a single value to be used for the whole collection. For any of
98-
these inputs, a Sequence of the specified type is also allowed.
99-
10096
Parameters
10197
----------
102-
edgecolors : color, default: :rc:`patch.edgecolor`
98+
edgecolors : color or list of colors, default: :rc:`patch.edgecolor`
10399
Edge color for each patch making up the collection. The special
104100
value 'face' can be passed to make the edgecolor match the
105101
facecolor.
106-
facecolors : color, default: :rc:`patch.facecolor`
102+
facecolors : color or list of colors, default: :rc:`patch.facecolor`
107103
Face color for each patch making up the collection.
108-
linewidths : float, default: :rc:`patch.linewidth`
104+
linewidths : float or list of floats, default: :rc:`patch.linewidth`
109105
Line width for each patch making up the collection.
110-
linestyles : str or tuple, default: 'solid'
106+
linestyles : str or tuple or list thereof, default: 'solid'
111107
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-',
112108
'--', '-.', ':']. Dash tuples should be of the form::
113109
@@ -120,10 +116,10 @@ def __init__(self,
120116
Style to use for capping lines for all paths in the collection.
121117
joinstyle : str, default: :rc:`patch.joinstyle`
122118
Style to use for joining lines for all paths in the collection.
123-
antialiaseds : bool, default: :rc:`patch.antialiased`
119+
antialiaseds : bool or list of bool, default: :rc:`patch.antialiased`
124120
Whether each pach in the collection should be drawn with
125121
antialiasing.
126-
offsets : (float, float), default: (0, 0)
122+
offsets : (float, float) or list thereof, default: (0, 0)
127123
A vector by which to translate each patch after rendering (default
128124
is no translation). The translation is performed in screen (pixel)
129125
coordinates (i.e. after the Artist's transform is applied).
@@ -152,7 +148,7 @@ def __init__(self,
152148
other hand, if it is greater than 0, then we instead check if the
153149
test point is contained in a stroke of width ``2*pickradius``
154150
following any of the Paths in the Collection.
155-
urls : str, default: None
151+
urls : list of str, optional, default: None
156152
A URL for each patch to link to once drawn. Currently only works
157153
for the SVG backend. See :doc:`/gallery/misc/hyperlinks_sgskip` for
158154
examples.
@@ -472,7 +468,7 @@ def set_urls(self, urls):
472468
"""
473469
Parameters
474470
----------
475-
urls : list of str or None
471+
urls : sequence of str or None
476472
477473
Notes
478474
-----
@@ -594,7 +590,7 @@ def set_linewidth(self, lw):
594590
595591
Parameters
596592
----------
597-
lw : float or sequence of floats
593+
lw : float or list of floats
598594
"""
599595
if lw is None:
600596
lw = mpl.rcParams['patch.linewidth']
@@ -629,8 +625,11 @@ def set_linestyle(self, ls):
629625
630626
Parameters
631627
----------
632-
ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
633-
The line style.
628+
ls : str or tuple or list thereof
629+
Valid values for individual linestyles include {'-', '--', '-.',
630+
':', '', (offset, on-off-seq)}. See
631+
`~.matplotlib.lines.Line2D.set_linestyle` for a complete
632+
description.
634633
"""
635634
try:
636635
if isinstance(ls, str):
@@ -660,7 +659,7 @@ def set_capstyle(self, cs):
660659
Parameters
661660
----------
662661
cs : {'butt', 'round', 'projecting'}
663-
The capstyle
662+
The capstyle.
664663
"""
665664
mpl.rcsetup.validate_capstyle(cs)
666665
self._capstyle = cs
@@ -675,7 +674,7 @@ def set_joinstyle(self, js):
675674
Parameters
676675
----------
677676
js : {'miter', 'round', 'bevel'}
678-
The joinstyle
677+
The joinstyle.
679678
"""
680679
mpl.rcsetup.validate_joinstyle(js)
681680
self._joinstyle = js
@@ -1019,9 +1018,10 @@ def legend_elements(self, prop="colors", num="auto",
10191018
10201019
Returns
10211020
-------
1022-
tuple (handles, labels)
1023-
with *handles* being a list of `.Line2D` objects
1024-
and *labels* a matching list of strings.
1021+
handles : list of `.Line2D`
1022+
Visual representation of each element of the legend.
1023+
labels : list of str
1024+
The string label for element of the legend.
10251025
"""
10261026
handles = []
10271027
labels = []
@@ -1102,11 +1102,11 @@ def __init__(self, verts, sizes=None, closed=True, **kwargs):
11021102
"""
11031103
Parameters
11041104
----------
1105-
verts : sequence
1105+
verts : sequence of array-like
11061106
The sequence of polygons [*verts0*, *verts1*, ...] where each
11071107
element *verts_i* defines the vertices of polygon *i* as a 2D
11081108
array-like of of shape (M, 2).
1109-
sizes : array-like, default: None
1109+
sizes : array-like of float, default: None
11101110
Squared scaling factors for the polygons. The coordinates of each
11111111
polygon *verts_i* are multiplied by the square-root of the
11121112
corresponding entry in *sizes* (i.e., *sizes* specify the scaling
@@ -1302,11 +1302,21 @@ class AsteriskPolygonCollection(RegularPolyCollection):
13021302

13031303

13041304
class LineCollection(Collection):
1305-
"""
1306-
Collection of 2D lines. Each line may have an arbitrary number of segments.
1305+
r"""
1306+
Represents a sequence of `~.lines.Line2D`\s that should be drawn together.
1307+
1308+
This class extends `.Collection` to represent a sequence of
1309+
`~.lines.Line2D`\s instead of just a sequence of `~.patches.Patch`\s.
1310+
Just as in `.Collection`, each property of a *LineCollection* may be either
1311+
a single value or a list of values. This list is then used cyclically for
1312+
each element of the LineCollection, so the property of the ``i``\th element
1313+
of the collection is::
13071314
1308-
Relevant parameters default to their ``'lines'`` values in
1309-
`~.matplotlib.rcParams` instead of their ``'patch'`` values.
1315+
prop[i % len(prop)]
1316+
1317+
A *LineCollection*'s properties default to their ``'lines'`` values in
1318+
`~.matplotlib.rcParams` instead of their ``'patch'`` values, and the
1319+
property *colors* is added in place of *edgecolors*.
13101320
"""
13111321

13121322
_edge_default = True
@@ -1326,32 +1336,25 @@ def __init__(self, segments, # Can be None.
13261336
**kwargs
13271337
):
13281338
"""
1329-
Except for *segments*, the type listed below is the expected type when
1330-
passing a single value to be used for the whole collection. A Sequence
1331-
of the specified type is also allowed, in which case the property for
1332-
the ``i``th element of the collection will be::
1333-
1334-
prop[i % len(prop)]
1335-
13361339
Parameters
13371340
----------
1338-
segments
1341+
segments: sequence of array-like
13391342
A sequence of (*line0*, *line1*, *line2*), where::
13401343
13411344
linen = (x0, y0), (x1, y1), ... (xm, ym)
13421345
13431346
or the equivalent numpy array with two columns. Each line
13441347
can have a different number of segments.
1345-
linewidths : float, default: :rc:`lines.linewidth`
1348+
linewidths : float or list of float, default: :rc:`lines.linewidth`
13461349
The width of each line in points.
1347-
colors : color, default: :rc:`lines.color`
1350+
colors : color or list of color, default: :rc:`lines.color`
13481351
A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not
13491352
allowed).
1350-
antialiaseds : default: :rc:`lines.antialiased`
1353+
antialiaseds : bool or list of bool, default: :rc:`lines.antialiased`
13511354
Whether to use antialiasing for each line.
13521355
zorder : int, default: 2
13531356
zorder of the lines once drawn.
1354-
facecolors : default: 'none'
1357+
facecolors : color or list of color, default: 'none'
13551358
The facecolors of the LineCollection.
13561359
Setting to a value other than 'none' will lead to each line being
13571360
"filled in" as if there was an implicit line segment joining the
@@ -1492,19 +1495,19 @@ def __init__(self,
14921495
linelength : float, default: 1
14931496
The total height of the marker (i.e. the marker stretches from
14941497
``lineoffset - linelength/2`` to ``lineoffset + linelength/2``).
1495-
linewidth : float, default: :rc:`lines.linewidth`
1498+
linewidth : float or list thereof, default: :rc:`lines.linewidth`
14961499
The line width of the event lines, in points.
14971500
color : color or list of colors, default: :rc:`lines.color`
14981501
The color of the event lines.
1499-
linestyle : str or tuple, default: 'solid'
1502+
linestyle : str or tuple or list thereof, default: 'solid'
15001503
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted',
15011504
'-', '--', '-.', ':']. Dash tuples should be of the form::
15021505
15031506
(offset, onoffseq),
15041507
15051508
where *onoffseq* is an even length tuple of on and off ink
15061509
in points.
1507-
antialiased : bool, default: :rc:`lines.antialiased`
1510+
antialiased : bool or list thereof, default: :rc:`lines.antialiased`
15081511
Whether to use antialiasing for drawing the lines.
15091512
**kwargs
15101513
Forwarded to `.LineCollection`.

0 commit comments

Comments
 (0)