I have a question related to using TeX in python.
I have the following packages included:
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 found in the previous question .
However, now I can also use the amsmath package fonts. When I include it in params, it does not respond. All I need amsmath for is to designate the x-axis of the graph with "a".
So, to show you what I have:

and what i want (regarding x-tag):

Note that to create a second image, I changed sfmath to amsmath . This will instantly ruin the x- and y-ticks. This is what I do not want.
Is it possible to change the font style of a single letter / word to amsmath style? That way, I could use this font style only when specifying the x-mark of my figure.
Another approach is to replace
sfmath with
amsmath with
params and make sure the ticks look like the first image.
thanks
On a side note, numbers were created using:
fig = plt.figure() ax1 = fig.add_subplot(1, 1, 1) ax1.set_xlabel(r"$a$", fontsize = 14) plt.show()