Skip to content

Commit 04acc1b

Browse files
authored
Merge pull request #15790 from timhoffm/doc-poly-collection
Update docs of PolyCollection
2 parents e3bf17e + ea6fd28 commit 04acc1b

File tree

4 files changed

+64
-43
lines changed

4 files changed

+64
-43
lines changed

lib/matplotlib/artist.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ def get_visible(self):
802802
return self._visible
803803

804804
def get_animated(self):
805-
"""Return the animated state."""
805+
"""Return whether the artist is animated."""
806806
return self._animated
807807

808808
def get_in_layout(self):
@@ -1072,7 +1072,7 @@ def sticky_edges(self):
10721072
return self._sticky_edges
10731073

10741074
def update_from(self, other):
1075-
'Copy properties from *other* to *self*.'
1075+
""""Copy properties from *other* to *self*."""
10761076
self._transform = other._transform
10771077
self._transformSet = other._transformSet
10781078
self._visible = other._visible

lib/matplotlib/cm.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,17 @@ def set_array(self, A):
256256
self.update_dict['array'] = True
257257

258258
def get_array(self):
259-
'Return the array'
259+
"""Return the data array."""
260260
return self._A
261261

262262
def get_cmap(self):
263-
'return the colormap'
263+
"""Return the `.Colormap` instance."""
264264
return self.cmap
265265

266266
def get_clim(self):
267-
'return the min, max of the color limits for image scaling'
267+
"""
268+
Return the values (min, max) that are mapped to the colormap limits.
269+
"""
268270
return self.norm.vmin, self.norm.vmax
269271

270272
def set_clim(self, vmin=None, vmax=None):

lib/matplotlib/collections.py

+56-37
Original file line numberDiff line numberDiff line change
@@ -1051,30 +1051,44 @@ class PolyCollection(_CollectionWithSizes):
10511051
@docstring.dedent_interpd
10521052
def __init__(self, verts, sizes=None, closed=True, **kwargs):
10531053
"""
1054-
*verts* is a sequence of ( *verts0*, *verts1*, ...) where
1055-
*verts_i* is a sequence of *xy* tuples of vertices, or an
1056-
equivalent :mod:`numpy` array of shape (*nv*, 2).
1057-
1058-
*sizes* is *None* (default) or a sequence of floats that
1059-
scale the corresponding *verts_i*. The scaling is applied
1060-
before the Artist master transform; if the latter is an identity
1061-
transform, then the overall scaling is such that if
1062-
*verts_i* specify a unit square, then *sizes_i* is the area
1063-
of that square in points^2.
1064-
If len(*sizes*) < *nv*, the additional values will be
1065-
taken cyclically from the array.
1066-
1067-
*closed*, when *True*, will explicitly close the polygon.
1068-
1069-
%(Collection)s
1054+
Parameters
1055+
----------
1056+
verts : sequence
1057+
The sequence of polygons [*verts0*, *verts1*, ...] where each
1058+
element *verts_i* defines the vertices of polygon *i* as a 2D
1059+
array-like of of shape (M, 2).
1060+
sizes : array-like, default: None
1061+
Squared scaling factors for the polygons. The coordinates of each
1062+
polygon *verts_i* are multiplied by the square-root of the
1063+
corresponding entry in *sizes* (i.e., *sizes* specify the scaling
1064+
of areas). The scaling is applied before the Artist master
1065+
transform. If *sizes* is shorter than *verts*, the additional
1066+
values will be taken cyclically from the *sizes*.
1067+
closed : bool, default: True
1068+
Whether the polygon should be closed by adding a CLOSEPOLY
1069+
connection at the end.
1070+
**kwargs
1071+
%(Collection)s
10701072
"""
10711073
Collection.__init__(self, **kwargs)
10721074
self.set_sizes(sizes)
10731075
self.set_verts(verts, closed)
10741076
self.stale = True
10751077

10761078
def set_verts(self, verts, closed=True):
1077-
'''This allows one to delay initialization of the vertices.'''
1079+
"""
1080+
Set the vertices of the polygons.
1081+
1082+
Parameters
1083+
----------
1084+
verts : sequence
1085+
The sequence of polygons [*verts0*, *verts1*, ...] where each
1086+
element *verts_i* defines the vertices of polygon *i* as a 2D
1087+
array-like of of shape (M, 2).
1088+
closed : bool, default: True
1089+
Whether the polygon should be closed by adding a CLOSEPOLY
1090+
connection at the end.
1091+
"""
10781092
if isinstance(verts, np.ma.MaskedArray):
10791093
verts = verts.astype(float).filled(np.nan)
10801094
# This is much faster than having Path do it one at a time.
@@ -1122,13 +1136,14 @@ class BrokenBarHCollection(PolyCollection):
11221136
@docstring.dedent_interpd
11231137
def __init__(self, xranges, yrange, **kwargs):
11241138
"""
1125-
*xranges*
1126-
sequence of (*xmin*, *xwidth*)
1127-
1128-
*yrange*
1129-
*ymin*, *ywidth*
1130-
1131-
%(Collection)s
1139+
Parameters
1140+
----------
1141+
xranges : sequence of (float, float)
1142+
The sequence of (left-edge-position, width) pairs for each bar.
1143+
yrange : (float, float)
1144+
The (lower-edge, height) common to all bars.
1145+
**kwargs
1146+
%(Collection)s
11321147
"""
11331148
ymin, ywidth = yrange
11341149
ymax = ymin + ywidth
@@ -1162,7 +1177,7 @@ def span_where(x, ymin, ymax, where, **kwargs):
11621177

11631178

11641179
class RegularPolyCollection(_CollectionWithSizes):
1165-
"""Draw a collection of regular polygons with *numsides*."""
1180+
"""A collection of n-sided regular polygons."""
11661181

11671182
_path_generator = mpath.Path.unit_regular_polygon
11681183
_factor = np.pi ** (-1/2)
@@ -1174,20 +1189,24 @@ def __init__(self,
11741189
sizes=(1,),
11751190
**kwargs):
11761191
"""
1177-
*numsides*
1178-
the number of sides of the polygon
1179-
1180-
*rotation*
1181-
the rotation of the polygon in radians
1182-
1183-
*sizes*
1184-
gives the area of the circle circumscribing the
1185-
regular polygon in points^2
1192+
Parameters
1193+
----------
1194+
numsides : int
1195+
The number of sides of the polygon.
1196+
rotation : float
1197+
The rotation of the polygon in radians.
1198+
sizes : tuple of float
1199+
The area of the circle circumscribing the polygon in points^2.
11861200
1187-
%(Collection)s
1201+
Other Parameters
1202+
----------------
1203+
**kwargs
1204+
Other keyword arguments.
1205+
%(Collection)s
11881206
1189-
Example: see :doc:`/gallery/event_handling/lasso_demo` for a
1190-
complete example::
1207+
Examples
1208+
--------
1209+
See :doc:`/gallery/event_handling/lasso_demo` for a complete example::
11911210
11921211
offsets = np.random.rand(20, 2)
11931212
facecolors = [cm.jet(x) for x in np.random.rand(20)]

lib/matplotlib/patches.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def contains_points(self, points, radius=None):
232232
radius)
233233

234234
def update_from(self, other):
235-
"""Updates this `.Patch` from the properties of *other*."""
235+
# docstring inherited.
236236
artist.Artist.update_from(self, other)
237237
# For some properties we don't need or don't want to go through the
238238
# getters/setters, so we just copy them directly.

0 commit comments

Comments
 (0)