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?
Use the set_title() Function to Add a Title to a Seaborn Plot. A seaborn plot returns a matplotlib axes instance type object. For such objects, we can use the set_title() function to add a title to the plot. We can also control the size of the title using the fontsize parameter.
Method 4: Using suptitle() method We can also use suptitle() method to add an overall title to the seaborn plot. This is mainly useful if you have many subplots, but you still need to use one single title to represent the seaborn charts.
In any case, the usual way to set the title is plt. title . The usual way to set the labels is plt. xlabel and plt.
To show the title for the diagram for Seaborn pairplot(), we can use pp. fig. suptitle() method.
try this:
sns.lmplot(x, y, data=df, hue="hue")
ax = plt.gca()
ax.set_title("Graph (a)")
seaborn
uses matplotlib
under the hood, so if you want a simple answer, use:
plt.title('My Title')
Right before
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With