美文网首页Python数据分析技术帖数据分析工具pandas快速入门教程
数据分析工具pandas快速入门教程3绘图3 seaborn

数据分析工具pandas快速入门教程3绘图3 seaborn

作者: python测试开发 | 来源:发表于2018-08-23 17:40 被阅读79次

matplotlib可以被认为是Python中的核心基础绘图工具,seaborn为matplotlib提供更高级别的统计图形接口。

  • 直方图
hist = sns.distplot(tips['total_bill'])
hist.set_title('Total Bill Histogram with Density Plot')
图片.png

默认distplot将绘制直方图和密度图(使用核密度估计)。如果我们只想要直方图,我们可以将kde参数设置为False。

hist = sns.distplot(tips['total_bill'], kde=False)
hist.set_title('Total Bill Histogram')
hist.set_xlabel('Total Bill')
hist.set_ylabel('Frequency')

图片.png
  • 单独输出密度图
hist = sns.distplot(tips['total_bill'], kde=False)
hist.set_title('Total Bill Histogram')
hist.set_xlabel('Total Bill')
hist.set_ylabel('Frequency')

图片.png
  • 地毯图
hist_den_rug = sns.distplot(tips['total_bill'], rug=True)
hist_den_rug.set_title('Total Bill Histogram with Density and Rug Plot')
hist_den_rug.set_xlabel('Total Bill')

图片.png
  • 条形图
count = sns.countplot('day', data=tips)
count.set_title('Count of days')
count.set_xlabel('Day of the Week')
count.set_ylabel('Frequency')
图片.png
  • 散点图
scatter = sns.regplot(x='total_bill', y='tip', data=tips)
scatter.set_title('Scatterplot of Total Bill and Tip')
scatter.set_xlabel('Total Bill')
scatter.set_ylabel('Tip')
图片.png

相关文章

网友评论

    本文标题:数据分析工具pandas快速入门教程3绘图3 seaborn

    本文链接:https://www.haomeiwen.com/subject/kqipiftx.html