From fdb8280007fc41dded8f616baad0a5a35029201c Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Thu, 9 May 2013 17:45:06 +0100 Subject: [PATCH] Fixed tight_layout pickle support. --- lib/matplotlib/tests/test_pickle.py | 6 ++++++ lib/matplotlib/text.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/matplotlib/tests/test_pickle.py b/lib/matplotlib/tests/test_pickle.py index 0af210e112e6..dfdad2ed20b4 100644 --- a/lib/matplotlib/tests/test_pickle.py +++ b/lib/matplotlib/tests/test_pickle.py @@ -115,6 +115,12 @@ def test_simple(): # recursive_pickle(ax, 'figure') # pickle.dump(ax, BytesIO(), pickle.HIGHEST_PROTOCOL) + fig = plt.figure() + plt.plot(range(10)) + fig.tight_layout(pad=0.3) + recursive_pickle(fig) + pickle.dump(fig, BytesIO(), pickle.HIGHEST_PROTOCOL) + @image_comparison(baseline_images=['multi_pickle'], extensions=['png'], remove_text=True) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index ec4c2f456670..78527f995ab6 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -197,6 +197,12 @@ def __init__(self, self.update(kwargs) #self.set_bbox(dict(pad=0)) + def __getstate__(self): + d = super(Text, self).__getstate__() + # remove the cached _renderer (if it exists) + d['_renderer'] = None + return d + def contains(self, mouseevent): """Test whether the mouse event occurred in the patch.