Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get list of font family(or Name of Font) in matplotlib

How can i get list of font family(or Name of Font) in matplotlib.

import matplotlib.font_manager
matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')

With help of this code i can get only directory of font. How can i get list of Font-Name like

"Century Schoolbook L", "Ubuntu".... etc

Thanks in Advance.

like image 784
Parth Gajjar Avatar asked Sep 16 '13 06:09

Parth Gajjar


People also ask

How do I get a list of fonts in Python?

To get a list of all the fonts currently available for matplotlib, we can use the font_manager. findSystemFonts() method.

What fonts are available in Matplotlib?

Matplotlib can use font families installed on the user's computer, i.e. Helvetica, Times, etc. Font families can also be specified with generic-family aliases like ( {'cursive', 'fantasy', 'monospace', 'sans', 'sans serif', 'sans-serif', 'serif'} ).

What is font family in Matplotlib?

There are five major generic font families in Matplotlib: 'serif' : Serifs are small decorative flourishes attached to stroke ends of characters. Fonts such as Times New Roman, Century, Garamond, and Palatino are serif fonts. 'sans-serif' : This means without serif.


1 Answers

Try following:

>>> import matplotlib.font_manager
>>> [f.name for f in matplotlib.font_manager.fontManager.ttflist]
['cmb10', 'cmex10', 'STIXNonUnicode', 'STIXNonUnicode', 'STIXSizeThreeSym', 'STIXSizeTwoSym', 'cmtt10', 'STIXGeneral', 'STIXSizeThreeSym', 'STIXSizeFiveSym', 'STIXSizeOneSym', 'STIXGeneral', 'cmr10', 'STIXSizeTwoSym', ...]
>>> [f.name for f in matplotlib.font_manager.fontManager.afmlist]
['Helvetica', 'ITC Zapf Chancery', 'Palatino', 'Utopia', 'Helvetica', 'Helvetica', 'ITC Bookman', 'Courier', 'Helvetica', 'Times', 'Courier', 'Helvetica', 'Utopia', 'New Century Schoolbook', ...]
like image 75
falsetru Avatar answered Sep 20 '22 08:09

falsetru