Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

seaborn FacetGrid: How to leave proper space on top for suptitle

Could someone show me how to leave extra space on top of a FacetGrid? I try to put a super title to the top of a FacetGrid plot but end up with the super-title overlapping with the subplot titles due to very limited margin on top in the default setting.

Thanks

like image 965
user3287545 Avatar asked Feb 20 '15 21:02

user3287545


2 Answers

Use the Figure method subplots_adjust to add space to the top of the plot:

g = sns.lmplot("x", "y", col="c", data=df)
g.fig.suptitle("Title of the plot", size=16)
g.fig.subplots_adjust(top=.9)
like image 142
mwaskom Avatar answered Sep 20 '22 14:09

mwaskom


.suptitle(...) is a matplotlib figure function. It has x and y arguments, with y=0.98 as the default. You can adjsut it to be a bit higher, instead of moving the subplots (in some cases you may not have enough freedom there).

g.fig.suptitle("My super title", y=1.05)
like image 42
Luce Avatar answered Sep 18 '22 14:09

Luce