我使用下面的代碼繪製了一系列使用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