使用数据帧pandas(ylabel)绘图

时间:2016-12-23 18:59:37

标签: python pandas plot dataframe

我有以下数据框:

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

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

var rangeValue;
var chanceoflive =0;
var inputElement = document.querySelector('.range-input');

inputElement.addEventListener('change', function() {
  var rangeValue = parseInt(this.value);
  chanceoflive = chanceoflive || 0;

  chanceoflive = rangeValue > 51 ? 2 : 4;
  }
);

function handleClick(){
    alert(chanceoflive);
}

enter image description here

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

1 个答案:

答案 0 :(得分:5)

索引将是yaxis标签,您可以尝试:

ax = frame1.set_index('Region').plot(kind="barh", align='center', color='blue')

enter image description here