pandas学习笔记(十一):绘图(Plotting)

(1)我们使用标准的matplotlib API参考来绘制数据图表

import matplotlib.pyplot as plt
plt.close('all')
ts = pd.Series(np.random.randn(10),index=pd.date_range('21/6/2020',periods=10))
ts = ts.cumsum()
ts.plot()

在这里插入图片描述

ts = pd.Series(np.random.randn(1000),index=pd.date_range('21/6/2020',periods=1000))
ts.plot()

在这里插入图片描述

df = pd.DataFrame(np.random.randn(1000, 5), index=ts.index, columns=['Golang', 'C', 'Asm', 'Js','Py'])
df = df.cumsum()
plt.figure()
df.plot()
plt.legend(loc='best')

在这里插入图片描述

from matplotlib.ticker import FuncFormatter

data = {'Barton LLC': 109438.50,
        'Frami, Hills and Schmidt': 103569.59,
        'Fritsch, Russel and Anderson': 112214.71,
        'Jerde-Hilpert': 112591.43,
        'Keeling LLC': 100934.30,
        'Koepp Ltd': 103660.54,
        'Kulas Inc': 137351.96,
        'Trantow-Barrows': 123381.38,
        'White-Trantow': 135841.99,
        'Will LLC': 104437.60}
group_data = list(data.values())
group_names = list(data.keys())
group_mean = np.mean(group_data)
fig, ax = plt.subplots()
ax.barh(group_names, group_data)

在这里插入图片描述

由于maplotlib的API太多,这里就不一一列举出来,还是到官网去查看效果要好的多,官网有很多的例子供参考

  • matplotlib官网网址:https://matplotlib.org/
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值