-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
Milestone
Description
Trying to save an unpickled figure using savefig throws an
AttributeError: 'CallbackRegistry' object has no attribute 'callbacks'
The issue is reproduced using the following code in python 2.7 (from WinPython2.7.10), Windows 8.1 (64bit), matplotlib 2.0.0
import matplotlib.pyplot as plt
import pickle
fig= plt.figure()
ax = fig.add_subplot(111)
ax.plot([9,8,7])
pickle.dump(fig, file('fig.pickle', 'w'))
plt.close("all")
fig_pickled1 = pickle.load(file('fig.pickle'))
plt.savefig(__file__+".png")
The traceback of the call to this is
Traceback (most recent call last):
File "D:\Data\Computer\Entwicklung\python\test\SO_pickle_matplotlib.py", line 43, in <module>
plt.savefig(__file__+".png")
File "C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\matplotlib\pyplot.py", line 697, in savefig
res = fig.savefig(*args, **kwargs)
File "C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\matplotlib\figure.py", line 1572, in savefig
self.canvas.print_figure(*args, **kwargs)
File "C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 222, in print_figure
FigureCanvasAgg.print_figure(self, *args, **kwargs)
File "C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\matplotlib\backend_bases.py", line 2163, in print_figure
self.figure.dpi = dpi
File "C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\matplotlib\figure.py", line 416, in _set_dpi
self.callbacks.process('dpi_changed', self)
File "C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\matplotlib\cbook.py", line 546, in process
if s in self.callbacks:
AttributeError: 'CallbackRegistry' object has no attribute 'callbacks'
Using plt.show() instead of saving works fine; the figure is shown as expected.
Using pickle.dump(fig, open('fig.pickle', 'wb')) for pickling and fig_pickled1 = pickle.load(open('fig.pickle', "rb")) does not change the behaviour.
Also, moving the loading to a new file has no effect.
Trying to save in other formats like pdf does not change anything.
Reactions are currently unavailable