How can I add a header on marine lmplot?

I am trying to add a title to 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 has no ax parameter. How to add title to my lmplot?

+8
source share
4 answers

try the following:

 sns.lmplot(x, y, data=df, hue="hue") ax = plt.gca() ax.set_title("Graph (a)") 
+8
source
 # 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) 
+3
source

As @jaykodeveloper pointed out in the comments, @MaxU answer works correctly if ax appears after:

 sns.lmplot(x, y, data=df, hue="hue") ax = plt.gca() ax.set_title("Graph (a)") 
+1
source
 sns.lmplot(x, y, data=df, hue="hue", ax=ax).fig.suptitle("Graph (a)") 
0
source

Source: https://habr.com/ru/post/1271955/


All Articles