Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 440086d

Browse files
committed
Merge pull request #1990 from pelson/tight_layout_pickle
Fixed tight_layout pickle support.
2 parents 5448d5b + fdb8280 commit 440086d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/matplotlib/tests/test_pickle.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ def test_simple():
115115
# recursive_pickle(ax, 'figure')
116116
# pickle.dump(ax, BytesIO(), pickle.HIGHEST_PROTOCOL)
117117

118+
fig = plt.figure()
119+
plt.plot(range(10))
120+
fig.tight_layout(pad=0.3)
121+
recursive_pickle(fig)
122+
pickle.dump(fig, BytesIO(), pickle.HIGHEST_PROTOCOL)
123+
118124

119125
@image_comparison(baseline_images=['multi_pickle'],
120126
extensions=['png'], remove_text=True)

lib/matplotlib/text.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ def __init__(self,
197197
self.update(kwargs)
198198
#self.set_bbox(dict(pad=0))
199199

200+
def __getstate__(self):
201+
d = super(Text, self).__getstate__()
202+
# remove the cached _renderer (if it exists)
203+
d['_renderer'] = None
204+
return d
205+
200206
def contains(self, mouseevent):
201207
"""Test whether the mouse event occurred in the patch.
202208

0 commit comments

Comments
 (0)