Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Fixed blitting in Gtk3Agg backend #1578

merged 1 commit into from

3 participants

spinnau Phil Elson Michael Droettboom

Fixed blitting in Gtk3Agg backend as described in issue #1575.

Phil Elson

Looks good to me. To all involved: is it possible to test this programatically?

Michael Droettboom

+1. I'm not sure how to test this, unfortunately, given that involves opening windows etc. I'd be happy to see this merged in any case.

Phil Elson pelson merged commit 7283784 into from

@pelson For testing you have to compare screenshots of opened windows. Thus, on linux machines a running XServer is needed. I don't know if it's the case on the build servers.

I have created a proposal for a test ( It compares two screenshots for normal plot and for blitting. Screenshots are taken with imagemagick. This works independent of the backend, so with a change of the GObject.idle_add line the test can be used for all blitting enabled backends. The imagemagick import command line tool doesn't work under Windows operating systems. Here PIL.ImageGrab could be used instead.

The images shows the screenshots for normal plot (left) and with blitting (right). Without the patch it can be seen, that the figure background and axes labels are missed.


The screenshots with the patch applied are not exact identical, there are some differences in the plot line thickness.


Michael Droettboom

It still likes it might be difficult to throw that test in our automated tests (which have to run without X etc), but maybe we should throw this in unit with some of our other off-line tests?


@mdboom If the automated tests have to run without XServer then using it as an off-line test seems to be the only possible solution. I have slightly enhanced the code for the test, so it now uses with a small tolerance value instead of PIL for comparing the images (

spinnau spinnau deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/matplotlib/backends/
14 lib/matplotlib/backends/
@@ -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.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
Something went wrong with that request. Please try again.