数据分析第三篇——Pandas画图

3.4 Pandas画图

  • 目标:
    • DataFrame的画图函数
    • 了解Series的画图函数
  • 内容预览:
    • 3.4.1 pandas.DataFrame.plot()
    • 3.4.2 pandas.Series.plot()

3.4.1 pandas.DataFrame.plot()

  • DataFrame.plot(x=None, y=None, kind=‘line’)

    • x : label or position, default None
    • y : label, position or list of label, positions, default None
      • Allows plotting of one column versus another
    • kind : str
      • ‘line’ : line plot (default)
      • ‘bar’ : vertical bar plot
      • ‘barth’ : horizontal bar plot
      • ‘hist’ : histogram
      • ‘pie’ : pie plot
      • ‘scatter’ : scatter plot
  • df.plot()无法显示中文的解决办法:


import matplotlib

matplotlib.rcParams['font.sans-serif']=['SimSun'] #用来正常显示中文标签

matplotlib.rcParams['axes.unicode_minus']=False #用来正常显示负号
data.plot(x='change', y='amount', kind='scatter')
<matplotlib.axes._subplots.AxesSubplot at 0x176fac31e08>

在这里插入图片描述

data.plot(x='vol', y='amount', kind='scatter')
<matplotlib.axes._subplots.AxesSubplot at 0x176fb0e2448>

在这里插入图片描述

data.plot(x='high', y='low', kind='scatter')
<matplotlib.axes._subplots.AxesSubplot at 0x176fac06b88>

在这里插入图片描述

3.4.2 pandas.Series.plot()

data['close'].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x176fb0d5b08>

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值