close

How to add a title to Seaborn Facet Plot

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to add a title to Seaborn Facet Plot in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to add a title to Seaborn Facet Plot?

  1. How to add a title to Seaborn Facet Plot?

    The FacetGrid objects are built with matplotlib Figure objects, so we can use subplots_adjustsuptitle that may be familiar from matplotlib in general.

  2. add a title to Seaborn Facet Plot

    The FacetGrid objects are built with matplotlib Figure objects, so we can use subplots_adjustsuptitle that may be familiar from matplotlib in general.

Method 1

Updating slightly, with seaborn 0.11.1:

Seaborn’s relplot function creates a FacetGrid and gives each subplot its own explanatory title. You can add a title over the whole thing:

import seaborn as sns
tips = sns.load_dataset('tips')

rp = sns.relplot(data=tips, x='total_bill', y='tip',
                 col='sex', row='smoker',
                 kind='scatter')
# rp is a FacetGrid; 
# relplot is a nice organized way to use it

rp.fig.subplots_adjust(top=0.9) # adjust the Figure in rp
rp.fig.suptitle('ONE TITLE FOR ALL')
Two-by-two grid of scatterplots. Each sub-plot has a title; the grid has a suptitle over all

If you create the FacetGrid directly, as in the original example, it automatically adds column and row labels instead of individual subplot titles. We can still add a title to the whole thing:

from matplotlib.pyplot import scatter as plt_scatter
g = sns.FacetGrid(tips, col='sex', row='smoker', 
                  margin_titles=True)
g.map(plt_scatter, 'total_bill', 'tip')
g.fig.subplots_adjust(top=0.9)
g.fig.suptitle('TITLE!')
Two-by-two grid of scatterplots. Each column has a title and the overall grid has a supertitle.

The FacetGrid objects are built with matplotlib Figure objects, so we can use subplots_adjustsuptitle that may be familiar from matplotlib in general.

Method 2

In ipython notebook, this worked for me!

sns.plt.title('YOUR TITLE HERE')

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read