使用“注释”时PDF格式的字体渲染

时间:2016-11-04 11:22:58

标签: python matplotlib

我正在使用matplotlib绘制一系列图表(在Linux Mint 18 - python 2.7.12中),使用下面的代码。但问题是,在生成PDF文件时,与“annotate”指令(plt.annotate())关联的字体的渲染非常糟糕。我找不到问题。有没有人有线索?

结果图片如下: enter image description here

(我希望你看到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')

1 个答案:

答案 0 :(得分:1)

它看起来不同,因为您多次打印这些标签(XX%)(每次运行)。

减少annotate命令的缩进(因此每个子图只运行一次)将解决问题

相关问题