继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

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

慕神8447489
关注TA
已关注
手记 1134
粉丝 172
获赞 955

直方图

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


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP