From ad70829c7f428b1f9de67d09aaefdf0ad27fee27 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 23 Dec 2019 18:51:41 +0100 Subject: [PATCH] Inherit the Artist.draw docstring in subclasses. --- lib/matplotlib/artist.py | 11 +++++--- lib/matplotlib/axes/_base.py | 2 +- lib/matplotlib/axis.py | 2 +- lib/matplotlib/figure.py | 5 +--- lib/matplotlib/legend.py | 2 +- lib/matplotlib/lines.py | 2 +- lib/matplotlib/offsetbox.py | 31 +++++----------------- lib/matplotlib/patches.py | 3 +-- lib/matplotlib/text.py | 9 ++----- lib/mpl_toolkits/axisartist/axis_artist.py | 2 +- 10 files changed, 23 insertions(+), 46 deletions(-) diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index 2294d5b1fa8a..bb4057706f26 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -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 diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 68a82ddd8332..c29fdd55ee52 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2613,7 +2613,7 @@ def _update_title_position(self, renderer): # Drawing @martist.allow_rasterization def draw(self, renderer=None, inframe=False): - """Draw everything (plot lines, axes, labels)""" + # docstring inherited if renderer is None: renderer = self.figure._cachedRenderer if renderer is None: diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index a52bd54ab0d5..c5e489de0381 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -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 diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 36a3d3253212..c1501f660fac 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -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 diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index 8a6dc90f6d7f..ba2750eac6f4 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -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 diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 4e9b4bfc0a0a..37ea625dfe40 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -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 diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index 9f9440abbc05..1e9144745433 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -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) @@ -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() @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index c8ae216b04a0..249cbac4e460 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -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: diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 3fd248bcc586..1f5dbc8849d4 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -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(): @@ -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(): diff --git a/lib/mpl_toolkits/axisartist/axis_artist.py b/lib/mpl_toolkits/axisartist/axis_artist.py index c1fb7d0cada3..f5cef8592ca4 100644 --- a/lib/mpl_toolkits/axisartist/axis_artist.py +++ b/lib/mpl_toolkits/axisartist/axis_artist.py @@ -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