2016-11-13 80 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时,你也会得到垂直标签。 –