这应该很容易,但我已经尝试了很多东西(基于seaborn relplot:如何控制图例的位置并添加标题,如何向Seaborn Facet Plot添加标题以及文档),但没有任何效果。
我尝试过的事情:
g = sns.relplot(x="col1", y="col2", data=df, height=6, aspect=2);
g.add_legend(title="Col1 x Col2");
Run Code Online (Sandbox Code Playgroud)
还:
g = sns.relplot(x="col1", y="col2", data=df, height=6, aspect=2).set_title('Col1 x Col2')
Run Code Online (Sandbox Code Playgroud)
和:
plt.title('Col1 x Col2')
g = sns.relplot(x="col1", y="col2", data=df, height=6, aspect=2);
Run Code Online (Sandbox Code Playgroud)
好吧,没有任何效果。我希望标题位于图表的顶部,就像 plt.title() 通常所做的那样。