I have the following simple python code:
import numpy as np
import matplotlib.pyplot as plt
plt.rc( 'font', size=20, family="Times" ) # use a font with serifs
# the following line triggers the problem
plt.rc( 'text', usetex=True ) # activate LaTeX text rendering
fig = plt.figure( figsize=(8,6) ) # (width,height) in inches
ax1 = fig.add_subplot( 1, 1, 1 ) # rows cols plotnumber
ax1.plot( np.linspace(1,10,10), np.linspace(1,10,10)**2 )
ax1.set_xlabel( r'\textit{x} in a.u.' )
ax1.set_ylabel( r'\textit{y} in a.u.' )
plt.show()
This results in the following figure:
As you can see, the tick-labels have a too thin font compared with the axes-labels (or the axes-labels are too thick). I have found out that this is due to activating the LaTeX text rendering (see comment in the code), but I have no clue how to change this as I do not want to switch the LaTeX text rendering off.
Any idea why the font-thickness (what is the plural of thickness?) is inconsistent and how to change that?
Update 1: Following the suggestion from llap42, a hack would be to do
plt.xticks([2, 4, 6, 8, 10], ['2', '4', '8', '10' ])
But that is only a hack and there has to be a better solution.
usetex
only applied to the labels. If you have a number in the label, is it thicker? (btw: thicknesses) – Enceusetex
also applies to numbers – Ninfaningalplt.rc()
matter? i.e. have you triedplt.rc('text', usetex=True)
first, and thenplt.rc('font', size=20, family="Times")
? – Kosakplt.rc('font',family = 'sans-serif', size=20)
. As can be seen the labels are sans-serif, but the ticklabels do not change. So instead of asking about 'font thickness', you should reword your question to why the ticklabels do not follow the font settings. – Pitching