Pandas plot画图

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

Series

data = pd.Series(np.random.randn(1000),index=np.arange(1000))
data = data.cumsum()
data.plot()
plt.show()
Pandas plot画图_第1张图片
Series plot.png

DataFrame

data = pd.DataFrame(np.random.randn(1000,4),index=np.arange(1000),columns=list("ABCD"))
data = data.cumsum()
print(data.head())
data.plot()
plt.show()

          A         B         C         D
0  2.830178 -1.266763  0.066207 -1.447268
1  2.304518 -0.271237  0.858129 -1.317108
2  1.795170  0.786167  0.407461 -0.883278
3  1.300544  1.846025  0.848325  0.076735
4  2.489885  4.499346  0.177688  0.565535
Pandas plot画图_第2张图片
DataFrame plot.png

plot methods:bar/hist/box/ked/area/scatter/hexbin/pie

abc = data.plot.scatter(x='A',y='B',color='DarkBlue',label='Class1')
data.plot.scatter(x='A',y='C',color='DarkGreen',label='Class2',ax=abc) #同一个绘图窗口
plt.show()
Pandas plot画图_第3张图片
scatter plot.png

Pandas学习教程来源请戳这里

你可能感兴趣的:(Pandas plot画图)