Skip to content

Deduplicate attribute docs of ContourSet and its derived classes #17799

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 1 commit into from
Jul 7, 2020
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
56 changes: 27 additions & 29 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

# Import needed for adding manual selection capability to clabel
from matplotlib.blocking_input import BlockingContourLabeler
from matplotlib import docstring

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


docstring.interpd.update(contour_set_attributes=r"""
Attributes
----------
ax : `~matplotlib.axes.Axes`
The Axes object in which the contours are drawn.

collections : `.silent_list` of `.LineCollection`\s or `.PathCollection`\s
The `.Artist`\s representing the contour. This is a list of
`.LineCollection`\s for line contours and a list of `.PathCollection`\s
for filled contours.

levels : array
The values of the contour levels.

layers : array
Same as levels for line contours; half-way between
levels for filled contours. See ``ContourSet._process_colors``.
""")


@docstring.dedent_interpd
class ContourSet(cm.ScalarMappable, ContourLabeler):
"""
Store a set of contour lines or filled regions.
Expand Down Expand Up @@ -707,20 +729,7 @@ class ContourSet(cm.ScalarMappable, ContourLabeler):
Keyword arguments are as described in the docstring of
`~.Axes.contour`.

Attributes
----------
ax
The axes object in which the contours are drawn.

collections
A silent_list of LineCollections or PolyCollections.

levels
Contour levels.

layers
Same as levels for line contours; half-way between
levels for filled contours. See :meth:`_process_colors`.
%(contour_set_attributes)s
"""

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


@docstring.dedent_interpd
class QuadContourSet(ContourSet):
"""
Create and store a set of contour lines or filled regions.

User-callable method: `~.Axes.clabel`

Attributes
----------
ax
The axes object in which the contours are drawn.

collections
A silent_list of LineCollections or PolyCollections.

levels
Contour levels.
This class is typically not instantiated directly by the user but by
`~.Axes.contour` and `~.Axes.contourf`.

layers
Same as levels for line contours; half-way between
levels for filled contours. See :meth:`_process_colors` method.
%(contour_set_attributes)s
"""

def _process_args(self, *args, corner_mask=None, **kwargs):
Expand Down
19 changes: 4 additions & 15 deletions lib/matplotlib/tri/tricontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,16 @@
from matplotlib.tri.triangulation import Triangulation


@docstring.dedent_interpd
class TriContourSet(ContourSet):
"""
Create and store a set of contour lines or filled regions for
a triangular grid.

User-callable method: clabel

Attributes
----------
ax
The axes object in which the contours are drawn.

collections
A silent_list of LineCollections or PolyCollections.

levels
Contour levels.
This class is typically not instantiated directly by the user but by
`~.Axes.tricontour` and `~.Axes.tricontourf`.

layers
Same as levels for line contours; half-way between
levels for filled contours. See :meth:`_process_colors`.
%(contour_set_attributes)s
"""
def __init__(self, ax, *args, **kwargs):
"""
Expand Down