2016-11-13 79 views
1

我具有以下熊貓數據幀,我想繪製NaNhigh值作爲matplotlib一個bar plot劇情條形圖數據幀

df 

       Close 1 Close 2 Close 3 Close 4 Close 5 Close 6 
Index                
NaN   0.000348 0.000975 0.001450 0.001923 0.002483 0.002916 
high   0.001416 -0.000215 0.000058 0.000026 -0.000766 -0.000255 

在x軸上的標籤應的列名。如何才能做到這一點?

非常感謝提前。

+1

試試這個:'df.T.plot.bar(腐= 0)' – MaxU

+0

@MaxU,謝謝。哇,我期待一個更長的解決方案,例如這裏介紹:http://matplotlib.org/examples/api/barchart_demo.html –

回答

1

您可以繪製調換DF:

In [9]: import matplotlib 
    ...: matplotlib.style.use('ggplot') 
    ...: 

In [10]: df.T.plot.bar(rot=0) 
Out[10]: <matplotlib.axes._subplots.AxesSubplot at 0xa1ae240> 

enter image description here

垂直標籤:

In [14]: df.T.plot.bar(width=0.85, alpha=0.6, figsize=(14,12)) 
Out[14]: <matplotlib.axes._subplots.AxesSubplot at 0xa3499e8> 

enter image description here

+0

完美。還有一個問題:標籤如何在此設置中垂直移調? –

+1

非常感謝。不會期望它那麼短。我注意到當你在初始答案中設置rot = 90時,你也會得到垂直標籤。 –