From 9b9f2f9a76cd60dafad9e39e9c0f417ac44b29b4 Mon Sep 17 00:00:00 2001 From: Cimarron Mittelsteadt Date: Sat, 7 Mar 2015 19:08:18 -0800 Subject: [PATCH] ENH/BUG: Fully save all GraphicsContext variables to a stack for the GraphicsContextMac class --- lib/matplotlib/backends/backend_macosx.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/matplotlib/backends/backend_macosx.py b/lib/matplotlib/backends/backend_macosx.py index 43434e374e1d..2ada24832410 100755 --- a/lib/matplotlib/backends/backend_macosx.py +++ b/lib/matplotlib/backends/backend_macosx.py @@ -185,6 +185,17 @@ class GraphicsContextMac(_macosx.GraphicsContext, GraphicsContextBase): def __init__(self): GraphicsContextBase.__init__(self) _macosx.GraphicsContext.__init__(self) + self._savestack = [] + + def save(self): + savedvars = vars(self).copy() + savedvars.pop('_savestack', None) + self._savestack.append(savedvars) + _macosx.GraphicsContext.save(self) + + def restore(self): + _macosx.GraphicsContext.restore(self) + vars(self).update(self._savestack.pop()) def set_alpha(self, alpha): GraphicsContextBase.set_alpha(self, alpha)