Skip to content

Commit 1b12cd5

Browse files
authored
Merge pull request #17799 from timhoffm/doc-tricontourset
Deduplicate attribute docs of ContourSet and its derived classes
2 parents 1664420 + 631eb32 commit 1b12cd5

File tree

2 files changed

+31
-44
lines changed

2 files changed

+31
-44
lines changed

lib/matplotlib/contour.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
# Import needed for adding manual selection capability to clabel
2525
from matplotlib.blocking_input import BlockingContourLabeler
26+
from matplotlib import docstring
2627

2728
# We can't use a single line collection for contour because a line
2829
# collection can have only a single line style, and we want to be able to have
@@ -667,6 +668,27 @@ def _find_closest_point_on_path(lc, point):
667668
return (dmin, xcmin, legmin)
668669

669670

671+
docstring.interpd.update(contour_set_attributes=r"""
672+
Attributes
673+
----------
674+
ax : `~matplotlib.axes.Axes`
675+
The Axes object in which the contours are drawn.
676+
677+
collections : `.silent_list` of `.LineCollection`\s or `.PathCollection`\s
678+
The `.Artist`\s representing the contour. This is a list of
679+
`.LineCollection`\s for line contours and a list of `.PathCollection`\s
680+
for filled contours.
681+
682+
levels : array
683+
The values of the contour levels.
684+
685+
layers : array
686+
Same as levels for line contours; half-way between
687+
levels for filled contours. See ``ContourSet._process_colors``.
688+
""")
689+
690+
691+
@docstring.dedent_interpd
670692
class ContourSet(cm.ScalarMappable, ContourLabeler):
671693
"""
672694
Store a set of contour lines or filled regions.
@@ -707,20 +729,7 @@ class ContourSet(cm.ScalarMappable, ContourLabeler):
707729
Keyword arguments are as described in the docstring of
708730
`~.Axes.contour`.
709731
710-
Attributes
711-
----------
712-
ax
713-
The axes object in which the contours are drawn.
714-
715-
collections
716-
A silent_list of LineCollections or PolyCollections.
717-
718-
levels
719-
Contour levels.
720-
721-
layers
722-
Same as levels for line contours; half-way between
723-
levels for filled contours. See :meth:`_process_colors`.
732+
%(contour_set_attributes)s
724733
"""
725734

726735
def __init__(self, ax, *args,
@@ -1378,26 +1387,15 @@ def find_nearest_contour(self, x, y, indices=None, pixel=True):
13781387
return (conmin, segmin, imin, xmin, ymin, dmin)
13791388

13801389

1390+
@docstring.dedent_interpd
13811391
class QuadContourSet(ContourSet):
13821392
"""
13831393
Create and store a set of contour lines or filled regions.
13841394
1385-
User-callable method: `~.Axes.clabel`
1386-
1387-
Attributes
1388-
----------
1389-
ax
1390-
The axes object in which the contours are drawn.
1391-
1392-
collections
1393-
A silent_list of LineCollections or PolyCollections.
1394-
1395-
levels
1396-
Contour levels.
1395+
This class is typically not instantiated directly by the user but by
1396+
`~.Axes.contour` and `~.Axes.contourf`.
13971397
1398-
layers
1399-
Same as levels for line contours; half-way between
1400-
levels for filled contours. See :meth:`_process_colors` method.
1398+
%(contour_set_attributes)s
14011399
"""
14021400

14031401
def _process_args(self, *args, corner_mask=None, **kwargs):

lib/matplotlib/tri/tricontour.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,16 @@
55
from matplotlib.tri.triangulation import Triangulation
66

77

8+
@docstring.dedent_interpd
89
class TriContourSet(ContourSet):
910
"""
1011
Create and store a set of contour lines or filled regions for
1112
a triangular grid.
1213
13-
User-callable method: clabel
14-
15-
Attributes
16-
----------
17-
ax
18-
The axes object in which the contours are drawn.
19-
20-
collections
21-
A silent_list of LineCollections or PolyCollections.
22-
23-
levels
24-
Contour levels.
14+
This class is typically not instantiated directly by the user but by
15+
`~.Axes.tricontour` and `~.Axes.tricontourf`.
2516
26-
layers
27-
Same as levels for line contours; half-way between
28-
levels for filled contours. See :meth:`_process_colors`.
17+
%(contour_set_attributes)s
2918
"""
3019
def __init__(self, ax, *args, **kwargs):
3120
"""

0 commit comments

Comments
 (0)