我正在尝试使用 Matplotlib 图表作为相机就绪的一部分
提交,出版社要求使用Type 1字体
仅有的。
我发现 PDF 后端很乐意输出 Type-1 字体
具有线性 Y 轴的简单图形,但输出 Type-3 字体
对数 Y 轴。
使用对数 yscale 会导致使用 mathtext,这似乎
使用 Type 3 字体,大概是因为默认使用指数字体
符号。我可以使用一个丑陋的黑客来解决这个问题 - 使用
pyplot.yticks() 强制轴刻度不使用指数 - 但是
这将需要移动绘图区域以容纳大标签
(如 10 ^ 6)或将轴写为 10、100、1K 等,以便它们适合。
我已经测试了下面的示例
截至今天的 matplotlib 主分支以及 1.1.1,它生成
相同的行为,所以我不知道这是一个错误,可能只是
意外的行为。
#!/usr/bin/env python
# Simple program to test for type 1 fonts.
# Generate a line graph w/linear and log Y axes.
from matplotlib import rc, rcParams
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
#rc('font',**{'family':'sans-serif','sans-serif':['computer modern sans serif']})
# These lines are needed to get type-1 results:
# http://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
rcParams['ps.useafm'] = True
rcParams['pdf.use14corefonts'] = True
rcParams['text.usetex'] = False
import matplotlib.pyplot as plt
YSCALES = ['linear', 'log']
def plot(filename, yscale):
plt.figure(1)
xvals = range(1, 2)
yvals = xvals
plt.plot(xvals, yvals)
plt.yscale(yscale)
plt.savefig(filename + '.pdf')
if __name__ == '__main__':
for yscale in YSCALES:
plot('linegraph-' + yscale, yscale)
有谁知道一种使用对数轴获取 Type 1 字体的干净方法吗?
Thanks!