我使用下面的代码绘制了一系列使用matplotlib(在Linux Mint 18 - python 2.7.12)中的图。但是,问题在于,当生成PDF文件时,与“annotate”指令(plt.annotate()
)相关的字体渲染非常糟糕。我找不到问题。有没有人有线索?使用“注释”时使用PDF进行字体渲染
产生的画面是这样的:
(我希望你看到,0%,10%...... 50%的注解有低分辨率)。其他带有注释的图没有相同的问题。 如果我放大图片,我看到这些注释呈现为矢量,但不知何故,它们与情节的其他字体呈现不同。
font = {'weight' : 'normal',
'size' : 8}
matplotlib.rc('font', **font)
concentrations = ["0","10","20","30","40","50"]
subplot = [ 321, 322, 323, 324, 325, 326 ]
runs = ["01","02","03","04","05","06","07","08","09","10"]
ic = -1
for c in concentrations :
ic = ic + 1
plt.subplot(subplot[ic])
for run in runs :
x, y = np.loadtxt(run+".dat",usecols=(0,1),comments="#",unpack=True)
plt.plot(x, y, 'b-', linewidth=1.0)
plt.xlim(0,1)
plt.ylim(0,r0[ic]+0.01)
plt.xticks(np.arange(0,1.1,0.25))
plt.annotate(c+"%", xy=(0.03, 0.02),**font)
plt.gcf().set_size_inches(3,4)
plt.gcf().savefig('../../tcf/alldecays.pdf')
我认为它可能是与字体BitstreamVeraSans罗马式3的粗体版本的问题也许尝试改变这个? –
删除前两行(字体设置)没有改善的情况 – dnalow