我被要求更改我的论文中使用Type 3字体的一些数字以使用Type 1字体,并且我发现instruction 做这个工作。Matplotlib:从类型3字体更改为类型1字体后.pdf中的非统一字体
加入以下3行,我能够产生一个Type 1字体.pdf文件:
matplotlib.rcParams['ps.useafm'] = True
matplotlib.rcParams['pdf.use14corefonts'] = True
matplotlib.rcParams['text.usetex'] = True
然而,当X-TICK和y蜱对我的老情节的字体是一致的,我添加了3行代码后,它们的字体变得不同了。这对我来说似乎很奇怪,因为这种变化只适用于其中一个蜱。
这里是脚本在python:
import matplotlib
matplotlib.use('PDF')
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
# Switch to Type 1 Fonts.
matplotlib.rcParams['ps.useafm'] = True
matplotlib.rcParams['pdf.use14corefonts'] = True
matplotlib.rcParams['text.usetex'] = True
def plot_pdf_figure(path, title, xl, yl, xt_list, yl_list, style_list):
fig = plt.figure(path)
ax = fig.add_subplot(111)
ax.set_title(title)
ax.set_xlabel(xl, style='italic')
ax.set_ylabel(yl)
x_list = range(0, len(xt_list))
plt.xticks(x_list, xt_list)
for y_list, style in zip(yl_list, style_list):
ax.plot(x_list, y_list, style)
pp = PdfPages(path)
pp.savefig(fig)
pp.close()
plot_pdf_figure("test_plot.pdf", "test", "x-axis", "y-axis", [1,2,3,4,5,6], [[1,2,4,8,16,32],[32,16,8,4,2,1]], ["-ro","-gs"])
谢谢你的任何指导或帮助!
它看起来并不像你实际上对rcParams进行更改。尝试在该块之前和之后删除'''''? – farenorth
这是为了比较。当前的代码将输出Type 3 Font,但删除'''将输出Type 1 Font,并且可以观察字体差异。如果不清楚,我会删除三个撇号。 – Sean