-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
The blitting in the Gtk3Agg backend will not work properly (mpl 1.2.0, Gtk 3.6.2, Python 2.7.3). Redrawing is done for the entire canvas, but only a part of the canvas area is used as a background image. Thus, some regions only shows white or grey space instead of their original content.
This can easily be reproduced with the matplotlib rectangle_selector example. If used with backend set to GtkAgg in matplotlibrc file, then all will be fine. With backend set to Gtk3Agg, only content of the axes is shown. The background of the figure together with the axes ticks and labels will be missed during blitting.
The reason is that the FigureCanvasGTK3Agg.blit()
method in backend_gtk3agg.py
invokes the queue_draw()
method of the Gtk widget, which redraws the entire area of the widget. Instead the queue_draw_area()
method should be used.
After applying the following patch to backend_gtk3agg.py the backend has the desired behavior:
--- backend_gtk3agg.py 2012-11-29 15:18:34.000000000 +0100 +++ backend_gtk3agg.py 2012-12-08 13:14:33.729618000 +0100 @@ -59,8 +59,21 @@ 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) d 5698 ef print_png(self, filename, *args, **kwargs): # Do this so we can save the resolution of figure in the PNG file
Thanks for all the nice work to get the new Gtk3 backends available,
Sebastian