How To Shift Suptitle In Seaborn Displot
For a plot as below. There is an issue whereby the Main title is on the same line with the other sub-title. May I know how shift the suptitle further up? The code to reproduce the
Solution 1:
.suptitle(...)
is a matplotlib figure function. It has x
and y
arguments, with y=0.98
as the default. You can adjust it to be a bit higher, instead of moving the subplots (in some cases you may not have enough freedom there).
import seaborn as sns
import matplotlib.pyplot as plt
iris = sns.load_dataset("iris")
fig=plt.figure()
#plt.suptitle("Main Title")
g = sns.displot ( data=iris, x='petal_width', col='species', col_wrap=2, bw_adjust=0.5, kind="kde", rug=True)
header_name =['1a','1b','1c','1d']
value_tick = [0.5,1,1.5,3]
g.set_xticklabels (rotation=45 )
g.fig.suptitle("My super title", y=1.05)
#plt.suptitle('Main title')
plt.xticks ( ticks=value_tick, labels=header_name, ha="right" )
Post a Comment for "How To Shift Suptitle In Seaborn Displot"