Custom Latex font for matplotlib

209 views Asked by At

I am trying to change Latex equations font so I used custom fonts and i'v tried various system fonts but the problem is however I change the font family only numbers changes not the characters(x and y in my example) itself.

from matplotlib import  rcParams
from matplotlib import pyplot as plt
import matplotlib
from matplotlib.font_manager import FontProperties

import matplotlib.font_manager
print([f.name for f in matplotlib.font_manager.fontManager.ttflist])

rcParams['mathtext.fontset'] = 'custom'
rcParams['mathtext.rm'] = 'STIXGeneral'
#rcParams['mathtext.rm'] = 'Corbel'
##rcParams['mathtext.rm'] = 'Arial'

matplotlib.rcParams.update({'font.size': 21})
fig, ay = plt.subplots()
plt.title("$x+y=21$")
plt.show()

STIXgeneral font output

Corbel font output

Arial font output

Any ideas what is going on? I am trying to get Stix2 math work.

0

There are 0 answers