2015-07-21 83 views
0

我有一个数据帧,看起来像这样:多个索引和图表熊猫

Species  POAPRA AGGREP 
R2    1  2 
D1    5  8 
D2    4  5 

,我想用下面的代码,使这一个图:

ax=df.plot(title='Invasive Species') 
ax.set_xlabel('Departure Level') 
ax.set_ylabel('Percent Occurance') 

这将产生

enter image description here

问题是我想让X轴显示R1,D1和D2 inst ead为0,0.5,1.0,1.5和2.0。我很确定我需要将第一列设置为索引,但由于我有多个索引,所以我不知道如何去做。

回答

2

只是在绘图之前​​到Species

ax=df.set_index('Species').plot(title='Invasive Species') 
ax.set_xlabel('Departure Level') 
ax.set_ylabel('Percent Occurance') 

enter image description here