matplotlib tex字体rcparams

时间:2015-10-21 00:09:53

标签: matplotlib fonts format latex tex

所有,我是 matplotlib 的新手。 使用font.weight时如何更改[text.usetex]: 在下面的代码中,我使用希腊符号(lambda)作为xaxis,但是当从latex文件生成pdf文件时,符号本身的重量似乎很轻,并且很难引人注意。

我不明白为什么设置font.weight='bold'没有效果。

我知道如何更改{lambda}符号的重量。请注意:我并不是要改变字体大小,而是改变字体重量。

提前谢谢!

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import matplotlib.gridspec as gridspec
from list2nparr import list2nparr

plt.rcParams['text.latex.preamble']=[r"\usepackage{lmodern}"]
plt.rcParams['text.usetex'] = True 
plt.rcParams['font.family'] = 'lmodern'
plt.rcParams['font.weight'] = 'bold'

fig = plt.figure()
for j in range(1,5):

  l = str(j)
  ax = fig.add_subplot(2,2,j)
  data = list2nparr('pwq'+l+'.txt')
  data2 = list2nparr('ssflux.dat')

  x  = data[:,0]
  y1 = data[:,1]
  y2 = data[:,2]
  y3 = data[:,3]
  y4 = data[:,4]

  mxval = []
  for i in range(len(x)):
     c= data[i,1]+data[i,2]+data[i,3]+data[i,4]
     mxval.append(c)

  fact = 26*max(mxval)
  xc = data2[:,0]
  yc = data2[:,1]
  yer = data2[:,2]

  ax.bar(x,y1, 1.6666, color='#FFA500',lw = 0.5)
  ax.bar(x,y2, 1.6666, color='#00BFFF',bottom = y1,lw=0.5)
  ax.bar(x,y3, 1.6666, color='m',bottom = y2+y1, lw=0.5)
  ax.bar(x,y4, 1.6666, color='g',bottom = y3+y2+y1,lw = 0.5)
  ax.errorbar(xc,yc*fact,yerr=yer*fact,fmt='o',c='k',mec='k',lw = 0.2, ms=2.5)
  plt.ylim(ymin=0)
  ax.tick_params(axis='both', labelsize=16)
  ax.ticklabel_format(style='sci',scilimits=(-3,4),axis='both',labelsize=17)  
#  ax.yaxis.major.formatter._useMathText = True

  if j == 1 or j == 2:
    ax.axes.xaxis.set_ticklabels([])

  if j == 1 or j == 3:
    plt.ylabel('N',rotation = 0,labelpad=20)

  if j == 3 or j == 4:
    plt.xlabel(r"$\lambda_{\odot}$, (deg)", fontsize=17,fontweight='bold')

plt.subplots_adjust(hspace=0.12)
plt.savefig('figure.eps', fmt = 'eps',bbox_inches='tight')

0 个答案:

没有答案