This question is specific to adding a title to a facet grid plot where only columns are defined, it is not answered by How to add a title to Seaborn Facet Plot.
I want to add a title to a FacetGrid where there is a single row of data, i.e. row=None
. When I do this the subplots_adjust
call doesn't seem to be applied correctly and the title clashes with the column headings.
Here I show that the method in use works correctly for a FacetGrid with col + row
data:
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col="sex", row="smoker", margin_titles=True)
g.map(sns.scatterplot, "total_bill", "tip")
g.fig.subplots_adjust(top=.9)
g.fig.suptitle('col and row - needs to be long to show issue', size=14)
g.savefig('col_and_row.png')
The same but omitting the row
:
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col="sex", margin_titles=True)
g.map(sns.scatterplot, "total_bill", "tip")
g.fig.subplots_adjust(top=.9)
g.fig.suptitle('col only - needs to be long to show issue', size=14)
g.savefig('col_only.png')
As you can see the title now clashes with the column headings:
Is this a bug or have I missed something?