pandas datafram绘制条形图

2024-04-27 04:56:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下pandas dataframe,我想在matplotlib中将NaNhigh值绘制为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轴上的标签应为列名。如何做到这一点?在

提前致谢。在


Tags: dataframepandasdfcloseindexplotmatplotlib绘制
1条回答
网友
1楼 · 发布于 2024-04-27 04:56:54

您可以绘制转置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

带垂直标签:

^{pr2}$

enter image description here

相关问题 更多 >