Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the font size of the legend in my Seaborn FactorPlot/FacetGrid?

The instructions from this question don't work for Seaborn FacetPlots. Would it be possible to get the method to do the same?

like image 595
tangy Avatar asked Dec 24 '22 07:12

tangy


2 Answers

A facetgrid legend is not part of the axes, but part of the facetgrid object. The legend is still a standard matplotlib legend and can be manipulated as such.

plt.setp(g._legend.get_title(), fontsize=20)

Where g is your facetgrid object returned after you call the function making it.

like image 98
Hielke Walinga Avatar answered Mar 22 '23 22:03

Hielke Walinga


If you're using a newer version of matplotlib there's an easier way to change legend font sizes -

plt.legend(fontsize='x-large', title_fontsize='40')

https://matplotlib.org/api/_as_gen/matplotlib.pyplot.legend.html

Might depend on the version of matplotlib you're using. I'm using 2.2.3 and it has the fontsize parameter but not the title_fontsize.

like image 21
Major Major Avatar answered Mar 22 '23 22:03

Major Major