How To Make Matplotlib Change Font?

Set a global font with `import matplotlib.pyplot as plt`

Update `plt.rcParams[‘font.family’] = ‘Your Font Name’`

Set a specific font for all text with `plt.rcParams[‘font.sans-serif’] = [‘Your Font Name’]`

Use `plt.rcParams[‘font.serif’] = [‘Your Serif Font Name’]` for serif fonts

Apply a font to a single title with `plt.title(‘Title’, fontname=’Your Font Name’)`

Apply a font to axis labels with `plt.xlabel(‘X Label’, fontname=’Your Font Name’)`

Apply a font to tick labels with `plt.xticks(fontname=’Your Font Name’)`

Use `from matplotlib import font_manager`

Load a font file with `font_manager.FontProperties(fname=’path/to/font.ttf’)`

Pass the font object to text with `plt.text(x, y, ‘Text’, fontproperties=font_prop)`

Use `plt.rcParams.update({‘font.family’: ‘Your Font Name’})`

Check installed fonts with `font_manager.findSystemFonts()`

Rebuild the font cache if a new font is not showing up

Restart the Python session after changing font settings

Suggested for You

Trending Today