Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added bar plot pickle support.
  • Loading branch information
pelson committed May 9, 2013
commit 695e8b547cb8fde49992fdbda4052b01c8d3e56e
7 changes: 7 additions & 0 deletions lib/matplotlib/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def remove(self):
if self._remove_method:
self._remove_method(self)

def __getstate__(self):
d = self.__dict__.copy()
# remove the unpicklable remove method, this will get re-added on load
# (by the axes) if the artist lives on an axes.
d['_remove_method'] = None
return d

def get_label(self):
"""
Get the label used for this artist in the legend.
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def test_simple():
# ax = plt.subplot(121, projection='hammer')
# recursive_pickle(ax, 'figure')
# pickle.dump(ax, BytesIO(), pickle.HIGHEST_PROTOCOL)

plt.figure()
plt.bar(left=range(10), height=range(10))
pickle.dump(plt.gca(), BytesIO(), pickle.HIGHEST_PROTOCOL)


@image_comparison(baseline_images=['multi_pickle'],
Expand Down