All, I am pretty new to matplotlib.
How could I change the font.weight
when using [text.usetex]
:
In the following code, I am using a greek symbol (lambda) for the xaxis but the weight of the symbol itself seems to be light and is poorly noticeable when a pdf file is produced from the latex file.
I don't understand why setting font.weight='bold'
doesn't have an effect.
Any idea how could I change the weight of the {lambda}
symbol. Please, NOTE: I don't mean to change the font size but the font weight.
Thank you in advance!
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')