Skip to content

Commit

Permalink
Merge pull request #2005 from mdboom/saving-animations
Browse files Browse the repository at this point in the history
Fail to export properly to svg and pdf with interactive paths
  • Loading branch information
mdboom committed May 16, 2013
2 parents 141c28b + 35e792f commit f3f3450
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2014,8 +2014,11 @@ def draw(self, renderer=None, inframe=False):
if self.axison and self._frameon:
artists.extend(self.spines.itervalues())

dsu = [ (a.zorder, a) for a in artists
if not a.get_animated() ]
if self.figure.canvas.is_saving():
dsu = [(a.zorder, a) for a in artists]
else:
dsu = [(a.zorder, a) for a in artists
if not a.get_animated()]

# add images to dsu if the backend support compositing.
# otherwise, does the manaul compositing without adding images to dsu.
Expand Down
11 changes: 11 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,13 +1485,21 @@ def __init__(self, figure):
self.scroll_pick_id = self.mpl_connect('scroll_event',self.pick)
self.mouse_grabber = None # the axes currently grabbing mouse
self.toolbar = None # NavigationToolbar2 will set me
self._is_saving = False
if False:
## highlight the artists that are hit
self.mpl_connect('motion_notify_event',self.onHilite)
## delete the artists that are clicked on
#self.mpl_disconnect(self.button_pick_id)
#self.mpl_connect('button_press_event',self.onRemove)

def is_saving(self):
"""
Returns `True` when the renderer is in the process of saving
to a file, rather than rendering for an on-screen buffer.
"""
return self._is_saving

def onRemove(self, ev):
"""
Mouse event processor which removes the top artist
Expand Down Expand Up @@ -2096,6 +2104,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
else:
_bbox_inches_restore = None

self._is_saving = True
try:
#result = getattr(self, method_name)(
result = print_method(
Expand All @@ -2114,6 +2123,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
self.figure.set_facecolor(origfacecolor)
self.figure.set_edgecolor(origedgecolor)
self.figure.set_canvas(self)
self._is_saving = False
#self.figure.canvas.draw() ## seems superfluous
return result

Expand Down Expand Up @@ -2160,6 +2170,7 @@ def switch_backends(self, FigureCanvasClass):
figure size or line props), will be reflected in the other
"""
newCanvas = FigureCanvasClass(self.figure)
newCanvas._is_saving = self._is_saving
return newCanvas

def mpl_connect(self, s, func):
Expand Down

0 comments on commit f3f3450

Please sign in to comment.