Seaborn 头衔位置

55t*_*iss 5 python location matplotlib title seaborn

我的图表标题在这方面的位置很糟糕jointplot。我试过移动loc = 'left, right,center但它没有从它所在的位置移动。我也尝试过ax.title.set_position([3, 15])基于本网站其他建议的类似方法,但也根本没有移动它。关于控制标题位置的任何建议?

sns.jointplot(leagueWinners_season['Wins'], leagueWinners_season['Goals'], kind = 'reg', color = 'b')
plt.title('Season Winners Goal and Win Regression', loc = 'right', fontsize = 16)

plt.show()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

She*_*ore 7

尝试使用

plt.title('Season Winners Goal and Win Regression', y=1.3, fontsize = 16)
Run Code Online (Sandbox Code Playgroud)

您可以y通过更改数字来调整位置。这里y轴的位置在相对坐标系中,这意味着y=1在图中的最高y位置,任何超过 1 的值都意味着将标题推得更高。


Dav*_*idG 7

另一种方法是使用plt.suptitle为图形提供居中的标题,然后使用subplots_adjust在图形顶部为标题留出更多空间:

plt.subplots_adjust(top=0.9)
plt.suptitle('Season Winners Goal and Win Regression', fontsize = 16)
Run Code Online (Sandbox Code Playgroud)