GCien
GCien

Reputation: 2349

matplotlib Histogram legend font family change

Very quick question. I would like to change the font family of a legend within the following:

ax.legend(loc='upper left', fontsize='xx-small', fontfamily=???)

However, I know that fontfamily is the wrong keyword argument. My question is, what is the right kwarg to do this?

I'm not sure what the right argument is, or if this is even possible without changing default rc parameters...

I have looked on stack overflow and on a host of other sites and help guides, but nothing specific to this.

Upvotes: 1

Views: 879

Answers (1)

Ajean
Ajean

Reputation: 5659

Legend has a keyword called prop (which is really for font properties ... why it's not fontprop or something like that I don't know) that you can use to specify font properties with a dictionary. Your line of code would look something like this if you wanted, say, the serif family:

ax.legend(loc='upper left', prop={'family':'serif', 'size':'xx-small'})

Notice you have to move the size specification into the dictionary with the rest, prop will override fontsize.

Upvotes: 3

Related Questions