2016-05-09 4 views
0

私はpandasプロット関数を使用して棒グラフを作成しようとしていますが、これはラインプロットを返すことになります。また、プレイヤー名でプロットにラベルを付けるにはどうすればいいですか?Pandas.plot(kind = 'bar')はラインプロットを返します

# Dummy Data Frame 
df = pd.DataFrame({'Player': ['A', 'B']*5, 
      'plActual' : np.random.randn(10), 
      'plPredict' : np.random.randn(10)}, 
     pd.date_range('1/1/2016', periods = 10)) 

# subplots by player 
df.groupby('Player').plot(kind='bar', subplots = True); 

私はPandasのバージョン0.17.1を使用しています。

enter image description here

+0

あなたはヒストグラムをしたいですか - の上に次のプロットを作成しますか? – Alexander

+0

私はちょうど線の代わりに縦棒をほしい - 毎日2つの棒(予測、実際)。ありがとう! – user2696565

+0

数値軸が2つあるので混乱している可能性があります。棒グラフには通常、カテゴリ軸があります。あなたの軸の1つを文字列に変換して、棒グラフをどこに置くかを知るようにしてください。 – Sam

答えて

1
players = {'A': 'Player A', 'B': 'Player B'} 

for player in df.Player.unique(): 
    df.loc[df.Player == player].plot(kind='bar', title=players.get(player)) 

enter image description here enter image description here

関連する問題