BUG: Fix blitting behavior in canvastools

This commit is contained in:
Tony S Yu
2012-11-15 21:56:51 -05:00
parent 5be5813070
commit d219a76f58
2 changed files with 5 additions and 7 deletions
+2 -2
View File
@@ -23,8 +23,8 @@ class CanvasToolBase(object):
useblit = True if mpl.backends.backend.endswith('Agg') else False
self.useblit = useblit
if useblit:
bbox = self.ax.bbox
self.img_background = self.canvas.copy_from_bbox(bbox)
self.canvas.draw()
self.img_background = self.canvas.copy_from_bbox(self.ax.bbox)
def connect_event(self, event, callback):
"""Connect callback with an event.
+3 -5
View File
@@ -23,9 +23,6 @@ class LineTool(CanvasToolBase):
lineprops=None):
super(LineTool, self).__init__(ax)
#TODO: Figure out how to cleanly restore image background for useblit
self.useblit = False
props = dict(color='r', linewidth=1, alpha=0.4, solid_capstyle='butt')
props.update(lineprops if lineprops is not None else {})
self.linewidth = props['linewidth']
@@ -105,8 +102,9 @@ class LineTool(CanvasToolBase):
def redraw(self):
if self.useblit:
# self.canvas.restore_region(self.img_background)
self.ax.draw_artist(self._line)
self.canvas.restore_region(self.img_background)
for artist in self._artists:
self.ax.draw_artist(artist)
self.canvas.blit(self.ax.bbox)
else:
self.canvas.draw_idle()