2016-12-23 44 views
1

我有跟隨的數據幀:使用繪圖數據框大熊貓(ylabel)

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 

我現在希望我的數據幀的繪製(HBAR)以上與地區的名稱ylabel,但是,我只Ÿ標籤上得到(0-4)的數量,如下所示:

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

enter image description here

我如何繪製針對每個區域的名字嗎? 在此先感謝

回答

5

該指數將是yaxis標籤,你可以試試這個:

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

enter image description here