以下是我的代码:
mpl.rcParams.update({'font.size': 18, 'font.weight': 'bold'})
mpl.rc('text', usetex=True)
plt.figure(figsize=(8, 7))
some data process
plot the data use pyplot.plot(x, y)
plt.legend(handles=[legend1,legend2,legend3,legend4], loc=8, numpoints=1)
plt.xlabel(r'$k_{s}$')
plt.ylabel(r'$P(k_{s})$')
plt.xlim(0.95, 100)
plt.tight_layout()
plt.savefig('fig3.eps', div=300, format='eps')
上面的代码将引发一个类型错误:调用savefig方法时无法将“bytes”对象隐式转换为str。在我的笔记本里不能看到我的图形。然而,其他格式如png、jpeg和pdf似乎也可以。在
我试图删除mpl.rc('text', usetex=True)
并删除所有的LaTex代码,然后异常就消失了。在
我的matplotlib版本是:1.5.1,python版本是3.5
我在google或matplotlib官方文档上找不到任何有用的信息。请帮我一把。谢谢大家!在
更新 我写一个简单的例子,事情不会改变。在
^{pr2}$预期结果显示在我的jupyter笔记本上,但它没有将fig保存到磁盘上。在
目前没有回答
相关问题 更多 >
编程相关推荐