为了账号安全,请及时绑定邮箱和手机立即绑定

python数据分析工具pandas数据可视化(绘图)快速入门1简单图

标签:
Python

直方图

titanic_data['Age'].hist()

使用Pandas数据框绘制年龄列的直方图是多么容易。

webp

image.png

可以将Matplotlib的参数传递给hist()方法,因为Pandas在使用了Matplotlib库。

titanic_data['Age'].hist(bins=20)

webp

image.png

通过导入Seaborn库设置set_style属性值来改进图的样式。 例如,让我们将网格的样式设置为深灰色。

import seaborn as sns  

sns.set_style('darkgrid')  
titanic_data['Age'].plot(kind='hist', bins=20)

数据帧有两种方法绘制图形。 一种方法是给传递plot函数传递kind参数:

titanic_data['Age'].plot(kind='hist', bins=20)

另一种方法是使用plot函数直接调用绘图的方法,参见前面的例子。

折线图

要使用Pandas数据帧绘制折线图,您必须使用plot函数调用line()方法并传递x和y轴的值,如下所示:

titanic_data.plot.line(x='Age', y='Fare', figsize=(8,6))

x轴包含乘客的年龄,而y轴包含乘客支付的票价。 figsize属性来改变绘图的大小,特别注意这个单位是英尺。

webp

image.png

散点图

titanic_data.plot.scatter(x='Age', y='Fare', figsize=(8,6))

webp

image.png

箱体图

titanic_data.plot.box(figsize=(10,8))

webp

image.png

六角形图

六边形图绘制了在x和y轴上交叉数据点的六边形。 点越多,六边形越暗。

titanic_data.plot.hexbin(x='Age', y='Fare', gridsize=30, figsize=(8,6))

webp

image.png

密度图

titanic_data.plot.hexbin(x='Age', y='Fare', gridsize=30, figsize=(8,6))

webp

image.png



作者:python作业AI毕业设计
链接:https://www.jianshu.com/p/d90a6643ea20


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消