Skip to content

Instantly share code, notes, and snippets.

@hongry18
Created September 9, 2019 03:39
Show Gist options
  • Save hongry18/51c16a41e7811197a1484809d8c82d2b to your computer and use it in GitHub Desktop.
Save hongry18/51c16a41e7811197a1484809d8c82d2b to your computer and use it in GitHub Desktop.
using matplotlib custom font in python
#!/bin/python
import matplotlib as mpl
import matplotlib.font_manager as font_manager
font_dirs = ['/my/custom/font/dir', ]
font_files = font_manager.findSystemFonts(fontpaths=font_dirs)
font_list = font_manager.createFontList(font_files)
font_manager.fontManager.ttflist.extend(font_list)
mpl.rcParams['axes.unicode_minus'] = False
mpl.rcParams['font.family'] = 'customFontName'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment