使用数据框pandas绘制图表(ylabel)

2024-09-27 07:33:15 发布

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

我有以下数据框:

 frame1 = pd.DataFrame(res.items(), columns=['Region', 'Ratio'])

    Region      Ratio
  0 Midwest     0.005669
  1 Northeast   0.008920
  2 North       0.006374
  3 South       0.002904
  4 Southeast   0.001928

现在我想用带有区域名称的ylabel绘制上面数据帧的(hbar),但是,我只得到y标签上的数字(0到4),如下所示:

  frame1['Ratio'].plot(y=frame1['Region'], x=frame1['Ratio'], kind="barh", align='center', color='blue')

enter image description here

如何绘制每个区域的名称? 提前谢谢


Tags: columns数据名称区域dataframe绘制itemsres

热门问题