Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add title on seaborn lmplot?

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?

like image 962
jayko03 Avatar asked Sep 19 '17 18:09

jayko03


People also ask

How do I add a title to my Seaborn heatmap?

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.

How do you add titles to subplots in Seaborn?

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.

How do you put a title on a scatter plot?

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.

How do I add a title to a Pairplot?

To show the title for the diagram for Seaborn pairplot(), we can use pp. fig. suptitle() method.


2 Answers

try this:

sns.lmplot(x, y, data=df, hue="hue")
ax = plt.gca()
ax.set_title("Graph (a)")
like image 158
MaxU - stop WAR against UA Avatar answered Sep 21 '22 16:09

MaxU - stop WAR against UA


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

plt.title('My Title')

Right before

plt.show()
like image 44
Nicolas Gervais Avatar answered Sep 18 '22 16:09

Nicolas Gervais