栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

直方图
titanic_data['Age'].hist()

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

image.png

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

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

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属性来改变绘图的大小,特别注意这个单位是英尺。

image.png

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

image.png

箱体图
titanic_data.plot.box(figsize=(10,8))

image.png

六角形图

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

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

image.png

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

image.png



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


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/221259.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号