Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53e82d3

Browse files
committed
Inline FigureCanvasGtkFoo._render_figure.
Having it as a separate function obscures the flow for little benefit, and caused an unnecessary call to get_allocation() in gtk3agg.
1 parent 26fd914 commit 53e82d3

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

lib/matplotlib/backends/backend_gtk3agg.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ def __init__(self, figure):
2020
def _renderer_init(self):
2121
pass
2222

23-
def _render_figure(self, width, height):
24-
backend_agg.FigureCanvasAgg.draw(self)
25-
2623
def on_draw_event(self, widget, ctx):
2724
"""GtkDrawable draw event, like expose_event in GTK 2.X."""
2825
allocation = self.get_allocation()
@@ -74,8 +71,7 @@ def blit(self, bbox=None):
7471

7572
def draw(self):
7673
if self.get_visible() and self.get_mapped():
77-
allocation = self.get_allocation()
78-
self._render_figure(allocation.width, allocation.height)
74+
backend_agg.FigureCanvasAgg.draw(self)
7975
super().draw()
8076

8177
def print_png(self, filename, *args, **kwargs):

lib/matplotlib/backends/backend_gtk3cairo.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ def _renderer_init(self):
2020
"""Use cairo renderer."""
2121
self._renderer = RendererGTK3Cairo(self.figure.dpi)
2222

23-
def _render_figure(self, width, height):
24-
self._renderer.set_width_height(width, height)
25-
self.figure.draw(self._renderer)
26-
2723
def on_draw_event(self, widget, ctx):
2824
"""GtkDrawable draw event."""
2925
with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
@@ -34,7 +30,9 @@ def on_draw_event(self, widget, ctx):
3430
self.get_style_context(), ctx,
3531
allocation.x, allocation.y,
3632
allocation.width, allocation.height)
37-
self._render_figure(allocation.width, allocation.height)
33+
self._renderer.set_width_height(
34+
allocation.width, allocation.height)
35+
self.figure.draw(self._renderer)
3836

3937

4038
@_BackendGTK3.export

0 commit comments

Comments
 (0)