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

Skip to content

Commit 6e63701

Browse files
committed
Fixed blitting in Gtk3Agg backend to redraw only area defined by bbox (#1575)
1 parent 745bb21 commit 6e63701

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/matplotlib/backends/backend_gtk3agg.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,20 @@ def on_draw_event(self, widget, ctx):
5959
return False
6060

6161
def blit(self, bbox=None):
62+
# If bbox is None, blit the entire canvas to gtk. Otherwise
63+
# blit only the area defined by the bbox.
64+
if bbox is None:
65+
bbox = self.figure.bbox
66+
67+
allocation = self.get_allocation()
68+
w, h = allocation.width, allocation.height
69+
x = int(bbox.x0)
70+
y = h - int(bbox.y1)
71+
width = int(bbox.x1) - int(bbox.x0)
72+
height = int(bbox.y1) - int(bbox.y0)
73+
6274
self._bbox_queue.append(bbox)
63-
self.queue_draw()
75+
self.queue_draw_area(x, y, width, height)
6476

6577
def print_png(self, filename, *args, **kwargs):
6678
# Do this so we can save the resolution of figure in the PNG file

0 commit comments

Comments
 (0)