17

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?

Archie
  • 2,247
  • 1
  • 18
  • 35
jayko03
  • 2,329
  • 7
  • 28
  • 51

4 Answers4

17

try this:

sns.lmplot(x, y, data=df, hue="hue")
ax = plt.gca()
ax.set_title("Graph (a)")
MaxU - stand with Ukraine
  • 205,989
  • 36
  • 386
  • 419
10

seaborn uses matplotlib under the hood, so if you want a simple answer, use:

plt.title('My Title')

Right before

plt.show()
Nicolas Gervais
  • 33,817
  • 13
  • 115
  • 143
8
# 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)
Tmu
  • 271
  • 3
  • 4
6
sns.lmplot(x, y, data=df, hue="hue", ax=ax).fig.suptitle("Graph (a)")
jamesrappazzo
  • 71
  • 3
  • 3