import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
ts=pd.Series(np.random.randn(1000),index=pd.date_range('2000/1/1',periods=1000))
ts=ts.cumsum()
ts.plot(title='Series cumsum',style='r--',figsize=(6,4))

df=pd.DataFrame(np.random.randn(1000,4),index=ts.index,columns=list('abcd'))
df=df.cumsum()
df.plot(title='DataFrame cumsum')

df.plot(subplots=True,sharey=True)

"""x轴默认是行索引,也可指定pandas某一类数据作为x轴"""
df.plot(x='d',y=['a','c'])

"""柱状图"""
df=pd.DataFrame(np.random.rand(10,4),columns=list('ABCD'))
df.iloc[0].plot(kind='bar')

df.plot.bar()

df.plot.bar(stacked=True)

"""直方图"""
df=pd.DataFrame(np.random.randn(1000,3),columns=list('abc'))
df['a'].hist(bins=20)

df.plot.hist(subplots=True,sharex=True,sharey=True)

df.plot.hist(alpha=0.3)

"""绘制概率密度"""
df['a'].plot.kde()


df.plot.kde()
df.mean()
a 0.018599
b 0.004607
c -0.053968
dtype: float64
df.std()
a 1.010327
b 1.038935
c 1.046297
dtype: float64
"""散点图画(x,y)点"""
df.plot.scatter(x='a',y='b')

"""饼图"""
s=pd.Series(3*np.random.rand(4),index=list('abcd'),name='series')
print(s)
s.plot.pie(labels=['A','b','C','orange'],autopct="%0.2f",fontsize=12)
a 2.970204
b 0.762244
c 1.206364
d 2.401405
Name: series, dtype: float64
