我想使我绘制的图形腌制,以获得一个“ .fig”文件。但是我看到关于逆向色彩图的错误。
我用this page来腌制。
然后我将Ubuntu 18.04.2 LTS与spyder和python 2.7一起使用
import pickle as pl
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import numpy as np
x = np.linspace(-np.pi, np.pi, 50)
y = np.linspace(-np.pi, np.pi, 50)
X,Y = np.meshgrid(x,y)
Z = np.sin(X + Y/4)
fig0 = plt.figure(figsize=(6, 4))
gs = plt.GridSpec(1,1)
ax3 = plt.subplot(gs[0,0])
im3 = ax3.pcolormesh(X,Y,Z, norm= LogNorm(), cmap=plt.get_cmap('afmhot_r'), shading='none')
cb3 = plt.colorbar(im3,format='%g',ax=ax3, label=r'$test$')
cb3.formatter = plt.LogFormatterMathtext(base=10)
cb3.update_ticks()
fig0.tight_layout()
savefig("test.eps")
pl.dump(fig0,file('test.fig.pickle','wb'))
这给了我以下错误代码:
File "/path_to_file/file.py", line 100, in <module>
pl.dump(fig0,file('test.fig.pickle','wb'))
File "/usr/lib/python2.7/pickle.py", line 1376, in dump
Pickler(file, protocol).dump(obj)
File "/usr/lib/python2.7/pickle.py", line 224, in dump
self.save(obj)
[...]
File "/usr/lib/python2.7/pickle.py", line 669, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 754, in save_global
(obj, module, name))
pickle.PicklingError: Can't pickle <function freversed at 0x7f4990062aa0>: it's not found as matplotlib.cm.freversed
如何腌制这种反转的颜色图?你有什么建议吗?