我正在尝试在Searborn lmplot上添加标题。
ax = plt.axes()
sns.lmplot(x, y, data=df, hue="hue", ax=ax)
ax.set_title("Graph (a)")
plt.show()
但我发现lmplot
没有ax
参数。如何在我的lmplot上添加标题?
我正在尝试在Searborn lmplot上添加标题。
ax = plt.axes()
sns.lmplot(x, y, data=df, hue="hue", ax=ax)
ax.set_title("Graph (a)")
plt.show()
但我发现lmplot
没有ax
参数。如何在我的lmplot上添加标题?
试试这个:
sns.lmplot(x, y, data=df, hue="hue")
ax = plt.gca()
ax.set_title("Graph (a)")
# 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)
seaborn
使用 matplotlib
作为其底层库,因此如果你需要简单的答案,请使用:
plt.title('My Title')
就在之前
plt.show()
sns.lmplot(x, y, data=df, hue="hue", ax=ax).fig.suptitle("Graph (a)")
plt.title("your title")
。 - Woody Pride