Python 以eps格式导出时,Matplotlib标签/标题将消失
我试图以eps格式保存matplotlib图形,但使用savefig()时,标签和标题都会消失。它适用于所有其他类型的输出,因此我不确定出了什么问题Python 以eps格式导出时,Matplotlib标签/标题将消失,python,matplotlib,Python,Matplotlib,我试图以eps格式保存matplotlib图形,但使用savefig()时,标签和标题都会消失。它适用于所有其他类型的输出,因此我不确定出了什么问题 import numpy as np import matplotlib.pyplot as plt data = np.random.rand(4,4) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(data) plt.title('Title') plt.xlabel('x axi
import numpy as np
import matplotlib.pyplot as plt
data = np.random.rand(4,4)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(data)
plt.title('Title')
plt.xlabel('x axis')
plt.ylabel('y axis')
fig.savefig('test.eps')
fig.savefig('test.png')
我从中得到的.png文件已正确标记(plt.show()看起来也不错),但.eps最终没有标签。有什么想法吗?(我仍在学习如何使用matplotlib,因此这可能是一个我忽略的简单修复…您正在使用的后端不支持您正在使用的字体包 尝试将matplotlib后端设置为已知后端之一。这必须在导入matplotlib之前完成 要了解当前设置了哪个后端,请参阅matplotlib.get_backend()
这听起来像是字体问题。您在哪个平台上?看起来后端已设置为TkAgg,但无法工作。我尝试将其切换为“PS”,因为我正在尝试获取.eps输出,但文本仍然不在那里…我会尝试“Qt4Agg”。ACK看起来我的eps查看软件也有问题,我显然应该早点查看。但是使用非交互式的“PS”后端工作起来很有魅力。谢谢
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt