pandas 如何在 seaborn lmplot 上添加标题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46307941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 04:29:28  来源:igfitidea点击:

How can I add title on seaborn lmplot?

pythonpandasmatplotlibdataframeseaborn

提问by jayko03

I am trying to add title on Searbon lmplot.

我正在尝试在 Searbon lmplot 上添加标题。

ax = plt.axes()
sns.lmplot(x, y, data=df, hue="hue", ax=ax)
ax.set_title("Graph (a)")
plt.show()

But I noticed that lmplotdoes not have an axparameter. How can I add a title on my lmplot?

但我注意到它lmplot没有ax参数。如何在我的 lmplot 上添加标题?

回答by MaxU

try this:

尝试这个:

sns.lmplot(x, y, data=df, hue="hue")
ax = plt.gca()
ax.set_title("Graph (a)")

回答by Tmu

# Create lmplot
lm = sns.lmplot(x, y, data=df, hue="hue", ax=ax)

# Access the figure
fig = lm.fig 

# Add a title to the Figure
fig.suptitle("My figtitle", fontsize=12)

回答by Nicolas Gervais

seabornuses matplotlibunder the hood, so if you want a simple answer, use:

seabornmatplotlib在引擎盖下使用,所以如果你想要一个简单的答案,请使用:

plt.title('My Title')

Right before

就在之前

plt.show()

回答by Jameswr.11

sns.lmplot(x, y, data=df, hue="hue", ax=ax).fig.suptitle("Graph (a)")