I have a question related to using TeX within python.
I have the following packages enabled:
import numpy
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rc('text', usetex = True)
matplotlib.rc('font', **{'family' : "sans-serif"})
params = {'text.latex.preamble' : [r'\usepackage{siunitx}', r'\usepackage{sfmath}']}
plt.rcParams.update(params)
The reason for this can be looked up in a previous question of mine.
However, I would now also be able to use the fonts of the amsmath
package. When I include it in params, it does not respond. All I need amsmath
for is to label the x-axis of a plot with "a".
So to show you what I have:
and what I want (regarding the x-label):
Please note that to produce the second image, I changed sfmath
into amsmath
. This immediatly messes up the x- and y-ticks. This is something I do not want to happen.
Is it perhaps possible to change the font style of a single letter/word to that of amsmath
? This way I would be able to only use that font style when indicating the x-label of my figure.
A different approach would be to replace sfmath
by amsmath
in params
and make sure the ticks look like the first image.
Thanks
On a side note, the figures were created using:
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)
ax1.set_xlabel(r"$a$", fontsize = 14)
plt.show()