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/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章