Search code examples
pythonseaborn

How to adjust space between relplot Seaborn subplots for multi-plot layouts


I am having a 2 x 1 subplot which is achievable as below.

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")
g = sns.relplot(x="total_bill", y="tip", hue="day", col="time", data=tips, facet_kws=dict(sharex=False),col_wrap=1)
g.set_xticklabels ( rotation=90, fontsize=18 )


plt.show ()

enter image description here

Currently, I have the issue whereby the x-tick label coincide with the bottom plot title.

How do I increase the spacing between the plots?


Solution

  • You can adjust the vertical spacing of the graph by using subplots_adjust().

    plt.subplots_adjust(hspace=0.2)
    

    enter image description here