Computer >> Computer tutorials >  >> Programming >> Python

How to get the list of font family (or Name of Fonts) in Matplotlib?


o get the list of font family in Matplotlib, we can take the following steps −

  • Iterate fonts manager ttflist and print the names.
  • Iterate fonts manager afmlist and print the names.

Example

import matplotlib.font_manager as fm
for f in fm.fontManager.ttflist:
   print(f.name)
for f in fm.fontManager.afmlist:
   print(f.name)

Output

STIXNonUnicode
STIXGeneral
STIXSizeFiveSym
cmr10
...
...
...
Nimbus Sans L
Bitstream Charter
Nimbus Sans L
Nimbus Sans L