How to add title to seaborn boxplot

前端 未结 5 1978
花落未央
花落未央 2020-12-12 16:16

Seems pretty Googleable but haven\'t been able to find something online that works.

I\'ve tried both sns.boxplot(\'Day\', \'Count\', data= gg).title(\'lalala\'

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 16:26

    sns.boxplot() function returns Axes(matplotlib.axes.Axes) object. please refer the documentation you can add title using 'set' method as below:

    sns.boxplot('Day', 'Count', data=gg).set(title='lalala')
    

    you can also add other parameters like xlabel, ylabel to the set method.

    sns.boxplot('Day', 'Count', data=gg).set(title='lalala', xlabel='its x_label', ylabel='its y_label')
    

    There are some other methods as mentioned in the matplotlib.axes.Axes documentaion to add tile, legend and labels.

提交回复
热议问题