The example of the result (computer modern font) is:
This page shows how to change text font of the labels, ticks and mathtext.
In [1]:
%matplotlib inline
In [2]:
import matplotlib.pyplot as plt
import numpy as np
In [3]:
x = np.linspace(0,1,100)
y1 = x**2
y2 = x**0.5
In [4]:
fonts1 = ["Times New Roman","Arial","Times New Roman"]
fonts2 = ["stix","stixsans","cm"]
for font1,font2 in zip(fonts1,fonts2):
plt.rcParams["font.family"] = font1
plt.rcParams["mathtext.fontset"] = font2
plt.rcParams["font.size"] = 20
plt.figure(facecolor="w")
plt.plot(x,y1,color="r")
plt.plot(x,y2,color="b")
plt.xlabel("x")
plt.ylabel(r"abcd $\alpha = x^2$,efgh $\beta = \sqrt{x}$")
plt.show()