I am trying to add title on 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 lmplot
does not have an ax
parameter.
How can I add a title on my lmplot?
try this:
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
uses matplotlib
under the hood, so if you want a simple answer, use:
plt.title('My Title')
Right before
plt.show()
sns.lmplot(x, y, data=df, hue="hue", ax=ax).fig.suptitle("Graph (a)")
plt.title("your title")