Question
Asked By – SirC
It sounds as an easy problem but I do not find any effective solution to change the font (not the font size) in a plot made with matplotlib in python.
I found a couple of tutorials to change the default font of matplotlib by modifying some files in the folders where matplotlib stores its default font – see this blog post – but I am looking for a less radical solution since I would like to use more than one font in my plot (text, label, axis label, etc).
Now we will see solution for issue: How to change fonts in matplotlib (python)?
Answer
Say you want Comic Sans for the title and Helvetica for the x label.
csfont = {'fontname':'Comic Sans MS'}
hfont = {'fontname':'Helvetica'}
plt.title('title',**csfont)
plt.xlabel('xlabel', **hfont)
plt.show()
This question is answered By – aidnani8
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0