Tune in tomorrow morning at 7:30 AM to hear an announcement from Caltech, MIT and the Laser Interferometer Gravitational-wave Observatory (LIGO): www.caltech.edu.
A digital lab notebook. Topics range from scientific computing using Python to neurobiology of Drosophila.
Wednesday, February 10, 2016
Monday, February 8, 2016
Changing font in matplotlib
In order to change the font of text in a matplotlib figure, I needed a list of the available fonts. It took me a frustratingly long time to find this stack exchange answer, so I thought I would record the solution here.
import matplotlib.font_manager
{f.name for f in matplotlib.font_manager.fontManager.ttflist}
Then just choose a name from the set and insert it into a text command, e.g.
import matplotlib.pyplot as plt
plt.ion()
plt.title('title', fontname='FreeSans')
Subscribe to:
Posts (Atom)