2017-08-09 31 views

回答

0

你需要情节列A只,指数在Series.plot用于x和值y默认:

#line is default method, so omitted 
Test['A'].plot(style='o') 

另一种解决方案是reset_indexindex列,然后DataFrame.plot

Test.reset_index().plot(x='index', y='A', style='o') 

样品:

Test=pd.DataFrame({'A':[3.0,4,5,10], 'B':[3.0,4,5,9]}) 
print (Test) 
     A B 
0 3.0 3.0 
1 4.0 4.0 
2 5.0 5.0 
3 10.0 9.0 

Test['A'].plot(style='o') 

graph


print (Test.reset_index()) 
    index  A B 
0  0 3.0 3.0 
1  1 4.0 4.0 
2  2 5.0 5.0 
3  3 10.0 9.0 

Test.reset_index().plot(x='index', y='A', style='o') 

graph1

+0

非常感谢您的帮助。如果我想让y轴从0运行到10,我该怎么做? – user234568

+0

您需要'ax = Test ['A']。plot(style ='o')' 'ax.set_ylim(0,10)' - 参见[here](https://stackoverflow.com/questions/17787366 /设定-y轴合matplotlib-使用-大熊猫) – jezrael