How to change legend fontname in matplotlib

Stu picture Stu · Feb 21, 2014 · Viewed 24.3k times · Source

I would like to display a font in Times New Roman in the legend of a matplotlib plot. I have changed all other tick labels/axis labels/titles to Times New Roman, and have searched the documentation but I can only find how to change the font size in a legend using the prop argument in pyplot.legend()


Of course straight after posting, I found the answer. Solution for anyone else with the same issue:

import matplotlib as mpl  
mpl.rc('font',family='Times New Roman')

Answer

Greg.S picture Greg.S · Mar 7, 2014

This wasn't showing up in google results so I'm going to post it as an answer. The rc parameters for font can be used to set a single default font.

Solution for anyone else with the same issue:

import matplotlib as mpl
mpl.rc('font',family='Times New Roman')