2016-04-28 8 views
0

私はデータフレームから行をプロットしようとしています - 私はデータフレームからエージェント同上1000000のレコードをスライスしてきたのPython 3.xのmatplotlibのプロット

print(df) 

Agent ID Tenure in Month As of 2014   City  State  P201101 \ 
0 1000000       65 Jersey City New Jersey 881.940392 

     P201102  P201103  P201104 P201105 P201106 ...  \ 
0 166.368261 1261.927008 531.211925 750.33716 357.73649 ...  

     P201306  P201307 P201308  P201309  P201310  P201311 \ 
0 1041.047706 639.671717 392.27343 860.148349 427.732344 972.562812 

     P201312 
0 593.675603  

、今私は毎月の売上データをプロットしたいです( P201101〜P201312)を使用した。以下は

は私のコードです - 残念ながら、x軸が値0,5,10を示し

x = list(df.columns[4:40]) 
y= df.iloc[:,4:40].values.tolist() 
plt.plot(y[0]) 
plt.show() 

.... .IはP201101、P201102を表示するにはx軸にしたい.... 。、P201312。私はxlabel、xticksを使ってみましたが、それは問題を解決しません。問題は、私が個別にx軸を指定している必要があることだった

enter image description here

答えて

0

助けてください。修正されたコードは次のようになります。

x=list(range(1,37)) 
xticks = list(df.columns[4:40]) 
y= df.iloc[:,4:40].values.tolist() 
print(x,y[0]) 
plt.plot(y[0]) 
plt.title("Agent ID "+str(list(df['Agent ID']))) 
plt.xticks(x,xticks,rotation = 90) 
plt.show() 
関連する問題