数据分析~pandas.Series 生成柱状图

2019-04-15 18:09发布

import numpy as np import pandas as pd import matplotlib.pyplot as plt #Series 生成柱状图 figure,pic=plt.subplots(2,1) data=pd.Series(np.random.rand(20),index=list('qwertyuiopasdfghjklz')) data.plot(kind='barh',ax=pic[0],figsize=(8,12),color='g') # data.plot(kind='bar',ax=pic[1],figsize=(8,12),color='r') plt.show() import numpy as np import pandas as pd import matplotlib.pyplot as plt # frame01=pd.DataFrame([[2,4,8,16,32,64],[3,5,12,24,48,96],[5,10,15,20,25,30],[1,3,5,7,9,11],[16,8,4,2,1,0.5]],index=range(0,100,20),columns=['A','B','C','D','E','F']) # pic,subplot=plt.subplots() # # frame01.plot(kind='line',ax=subplot,subplots=False,layout=False,logx=True,xlim=[0,100]) # frame01.plot(style='*--',ax=subplot,subplots=False,layout=False,logx=True,xlim=[0,100]) # plt.show() #Series 生成柱状图 figure,pic=plt.subplots(2,1) data=pd.Series(np.random.rand(20),index=list('qwertyuiopasdfghjklz')) # data.plot(kind='barh',ax=pic[0],figsize=(8,12),color='g') data.plot(kind='bar',ax=pic[1],figsize=(8,12),color='r') plt.show()