diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index c52ffee90c25..023174c68635 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -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. diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index e950ea335a8f..8abff141cc3a 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1485,6 +1485,7 @@ 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) @@ -1492,6 +1493,13 @@ def __init__(self, figure): #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 @@ -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( @@ -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 @@ -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):