diff --git a/lib/matplotlib/backends/backend_gtk3agg.py b/lib/matplotlib/backends/backend_gtk3agg.py index be59670bb426..8e5b991daf80 100644 --- a/lib/matplotlib/backends/backend_gtk3agg.py +++ b/lib/matplotlib/backends/backend_gtk3agg.py @@ -26,7 +26,6 @@ def on_draw_event(self, widget, ctx): w, h = allocation.width, allocation.height if not len(self._bbox_queue): - self._render_figure(w, h) Gtk.render_background( self.get_style_context(), ctx, allocation.x, allocation.y, @@ -71,6 +70,12 @@ def blit(self, bbox=None): self._bbox_queue.append(bbox) self.queue_draw_area(x, y, width, height) + def draw(self): + if self.get_visible() and self.get_mapped(): + allocation = self.get_allocation() + self._render_figure(allocation.width, allocation.height) + super().draw() + def print_png(self, filename, *args, **kwargs): # Do this so we can save the resolution of figure in the PNG file agg = self.switch_backends(backend_agg.FigureCanvasAgg)