matplotlib是比较低级的工具,而pandas提供更为高级的方法

线型图

Series和DataFrame都有用于生成各类图标的plot方法,默认它们生成的是线型图

s = Series(np.random.randn(10).cumsum(), index=np.arange(0, 100, 10))
s.plot()

Series对象的索引会传给matplotlib,用于绘制X轴。

DataFrame的plot方法会在一个subpot中为各列绘制一条线,并自动创建图例

df = DataFrame(np.random.randn(10, 4).cumsum(0),
               columns=['A', 'B', 'C', 'D'],
               index=np.arange(0, 100, 10))
df.plot()

results matching ""

    No results matching ""