From 6e6370177db95173aa91c4961f066b7395ffda6c Mon Sep 17 00:00:00 2001 From: Sebastian Pinnau Date: Sun, 9 Dec 2012 11:53:31 +0100 Subject: [PATCH] Fixed blitting in Gtk3Agg backend to redraw only area defined by bbox (#1575) --- lib/matplotlib/backends/backend_gtk3agg.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_gtk3agg.py b/lib/matplotlib/backends/backend_gtk3agg.py index c05e0266631a..ada6da4d5d50 100644 --- a/lib/matplotlib/backends/backend_gtk3agg.py +++ b/lib/matplotlib/backends/backend_gtk3agg.py @@ -59,8 +59,20 @@ def on_draw_event(self, widget, ctx): return False def blit(self, bbox=None): + # If bbox is None, blit the entire canvas to gtk. Otherwise + # blit only the area defined by the bbox. + if bbox is None: + bbox = self.figure.bbox + + allocation = self.get_allocation() + w, h = allocation.width, allocation.height + x = int(bbox.x0) + y = h - int(bbox.y1) + width = int(bbox.x1) - int(bbox.x0) + height = int(bbox.y1) - int(bbox.y0) + self._bbox_queue.append(bbox) - self.queue_draw() + self.queue_draw_area(x, y, width, height) def print_png(self, filename, *args, **kwargs): # Do this so we can save the resolution of figure in the PNG file