Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Description
I know pickling of figures (awesome!) is still experimental, but it seems bar plots have problems.recursive_pickle()
seems to give a more detailed traceback thanpickle.dump()
:
from matplotlib.tests.test_pickle import recursive_picklefrom pylab import figure, barfig = figure()bar(left=range(10), height=range(10))recursive_pickle(fig)
gives:
Line2D((0,0),(0,1))Failed to pickle attribute "gridline" in (list/tuple item #0 in (attribute "majorTicks" in(attribute "xaxis" in (list/tuple item #1 in (list/tuple item #1 in (list/tuple item #0 in(attribute "_elements" in (attribute "_axstack" in (top level object))))))))). Type: <class 'matplotlib.lines.Line2D'>. Traceback follows:---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-9-b0c9db9f3303> in <module>()----> 1 recursive_pickle(fig)/home/mspacek/src/matplotlib/lib/matplotlib/tests/test_pickle.pyc in recursive_pickle(top_obj) 88 # print('trying %s' % location) 89 try:---> 90 pickle.dump(obj, BytesIO(), pickle.HIGHEST_PROTOCOL) 91 except Exception, err: 92 print(obj)TypeError: expected string or Unicode object, NoneType found
Usingpickle.dump()
instead like this:
import picklefrom io import BytesIOfrom pylab import figure, barfig = figure()bar(left=range(10), height=range(10))pickle.dump(fig, BytesIO(), pickle.HIGHEST_PROTOCOL)
gives a different error:
PicklingError: Can't pickle <built-in method copy_from_bbox of tuple object at 0x3406a70>:it's not found as __main__.copy_from_bbox
This is in master on Python 2.7 on Ubuntu 12.10.