Skip to content

Inherit the Artist.draw docstring in subclasses. #16010

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
Dec 25, 2019
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
11 changes: 7 additions & 4 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,15 +902,18 @@ def set_agg_filter(self, filter_func):

def draw(self, renderer, *args, **kwargs):
"""
Draw the Artist using the given renderer.
Draw the Artist (and its children) using the given renderer.

This method will be overridden in the Artist subclasses. Typically,
it is implemented to not have any effect if the Artist is not visible
(`.Artist.get_visible` is *False*).
This has no effect if the artist is not visible (`.Artist.get_visible`
returns False).

Parameters
----------
renderer : `.RendererBase` subclass.

Notes
-----
This method is overridden in the Artist subclasses.
"""
if not self.get_visible():
return
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2613,7 +2613,7 @@ def _update_title_position(self, renderer):
# Drawing
@martist.allow_rasterization
def draw(self, renderer=None, inframe=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the parameters here? They're undocumented (though they were before too).

"""Draw everything (plot lines, axes, labels)"""
# docstring inherited
if renderer is None:
renderer = self.figure._cachedRenderer
if renderer is None:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ def get_tick_padding(self):

@martist.allow_rasterization
def draw(self, renderer, *args, **kwargs):
'Draw the axis lines, grid lines, tick lines and labels'
# docstring inherited

if not self.get_visible():
return
Expand Down
5 changes: 1 addition & 4 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,10 +1666,7 @@ def clear(self, keep_observers=False):

@allow_rasterization
def draw(self, renderer):
"""
Render the figure using :class:`matplotlib.backend_bases.RendererBase`
instance *renderer*.
"""
# docstring inherited
self._cachedRenderer = renderer

# draw the figure bounding box, perhaps none for white figure
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def _findoffset(self, width, height, xdescent, ydescent, renderer):

@allow_rasterization
def draw(self, renderer):
"Draw everything that belongs to the legend."
# docstring inherited
if not self.get_visible():
return

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ def _is_sorted(self, x):

@allow_rasterization
def draw(self, renderer):
# docstring inherited from Artist.draw.
# docstring inherited

if not self.get_visible():
return
Expand Down
31 changes: 7 additions & 24 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,7 @@ def get_extent_offsets(self, renderer):
[(0, 0)])

def draw(self, renderer):
"""
Update the location of children if necessary and draw them
to the given *renderer*.
"""
# docstring inherited
width, height, xdescent, ydescent, offsets = self.get_extent_offsets(
renderer)

Expand Down Expand Up @@ -745,9 +742,7 @@ def add_artist(self, a):
a.set_figure(fig)

def draw(self, renderer):
"""
Draw the children
"""
# docstring inherited

dpi_cor = renderer.points_to_pixels(1.)
self.dpi_transform.clear()
Expand Down Expand Up @@ -916,12 +911,8 @@ def get_extent(self, renderer):
return w, h, 0., d

def draw(self, renderer):
"""
Draw the children
"""

# docstring inherited
self._text.draw(renderer)

bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
self.stale = False

Expand Down Expand Up @@ -1012,13 +1003,9 @@ def get_extent(self, renderer):
return ub.width, ub.height, 0., 0.

def draw(self, renderer):
"""
Draw the children
"""

# docstring inherited
for c in self._children:
c.draw(renderer)

bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
self.stale = False

Expand Down Expand Up @@ -1217,7 +1204,7 @@ def update_frame(self, bbox, fontsize=None):
self.patch.set_mutation_scale(fontsize)

def draw(self, renderer):
"draw the artist"
# docstring inherited

if not self.get_visible():
return
Expand Down Expand Up @@ -1412,9 +1399,7 @@ def get_extent(self, renderer):
return w, h, 0, 0

def draw(self, renderer):
"""
Draw the children
"""
# docstring inherited
self.image.draw(renderer)
# bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
self.stale = False
Expand Down Expand Up @@ -1630,9 +1615,7 @@ def _update_position_xybox(self, renderer, xy_pixel):
self.arrow_patch.set_patchA(patchA)

def draw(self, renderer):
"""
Draw the :class:`Annotation` object to the given *renderer*.
"""
# docstring inherited

if renderer is not None:
self._renderer = renderer
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,9 @@ def _bind_draw_path_function(self, renderer):

@artist.allow_rasterization
def draw(self, renderer):
"""Draw to the given *renderer*."""
# docstring inherited
if not self.get_visible():
return

# Patch has traditionally ignored the dashoffset.
with cbook._setattr_cm(self, _dashoffset=0), \
self._bind_draw_path_function(renderer) as draw_path:
Expand Down
9 changes: 2 additions & 7 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,7 @@ def _get_wrapped_text(self):

@artist.allow_rasterization
def draw(self, renderer):
"""
Draws the `.Text` object to the given *renderer*.
"""
# docstring inherited
if renderer is not None:
self._renderer = renderer
if not self.get_visible():
Expand Down Expand Up @@ -1945,10 +1943,7 @@ def _update_position_xytext(self, renderer, xy_pixel):

@artist.allow_rasterization
def draw(self, renderer):
"""
Draw the :class:`Annotation` object to the given *renderer*.
"""

# docstring inherited
if renderer is not None:
self._renderer = renderer
if not self.get_visible():
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axisartist/axis_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ def get_tightbbox(self, renderer):

@martist.allow_rasterization
def draw(self, renderer):
"""Draw the axis lines, tick lines and labels."""
# docstring inherited

if not self.get_visible():
return
Expand Down