当前位置: 首页 > 后端技术 > Python

Python数据分析 - seaborn工具与数据可视化

时间:2023-03-26 17:43:06 Python

undefined方法很简单,只需要在绘图前放置Seaborn提供的样式声明代码sns.set()即可。importseabornassnssns.set()#声明使用Seaborn样式plt.bar(x,y_bar)plt.plot(x,y_line,'-o',color='y')可以查到,相比Matplotlib默认的pure搭配白色背景,Seaborn默认的浅灰色网格背景看起来确实更加精致舒适。直方图的色调和坐标轴的字体大小也有一些变化。sns.set()的默认参数是:sns.set(context='notebook',style='darkgrid',palette='deep',font='sans-serif',font_scale=1,color_codes=False,rc=None)context=''参数控制默认的framesize,有四个值分别为{paper,notebook,talk,poster}。其中,海报>谈话>笔记本>纸。style=''参数控制默认的样式,包括{darkgrid,whitegrid,dark,white,ticks},大家可以自己改,看看它们的区别。palette=''参数为预设调色板。有{deep,muted,bright,pastel,dark,colorblind}等等,你可以自己改一下看看它们的区别。剩下的font=''用来设置字体,font\_scale=设置字体大小,color\_codes=不使用调色板而是使用前面的颜色缩写比如‘r’。3.Seaborn核心绘图函数和方法Seaborn一共有50多个API类,相对于成千上万的Matplotlib来说可以说是非常精简了。undefinedundefinedundefinedundefinedundefinedundefinedundefined