如何在seaborn lmplot上添加标题?

时间:2017-09-19 18:58:11

标签: python pandas matplotlib dataframe seaborn

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

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

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

4 个答案:

答案 0 :(得分:7)

试试这个:

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

答案 1 :(得分:2)

# 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)

答案 2 :(得分:1)

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

答案 3 :(得分:1)

seaborn在幕后使用matplotlib,因此,如果您想要一个简单的答案,请使用:

plt.title('My Title')

就在

之前
plt.show()
相关问题