【3.1】seaborn添加title

Seaborn box plot返回的是matplotlib axes的实例. 跟pyplot不一样, pyplot有plt.title()方法, Seaborn需要通过ax.set_title()来添加title

方法一(set_title):

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")
sns.boxplot(x=tips["total_bill"]).set_title("LaLaLa")

plt.show()

方法二(返回值ax的set_title):

ax = sns.boxplot('Day', 'Count', data= gg)
ax.set_title('lalala')
ax.set_ylabel('lololo')

参考资料

https://stackoverflow.com/questions/42406233/how-to-add-title-to-seaborn-boxplot

药企,独角兽,苏州。团队长期招人,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn