python - How can I define scope for plotting graph in Pandas? -


i trying plot dataframe pandas. don't know how can define y , x-axis scales. example, in following, want show graph 1.0 0.0 in terms of y-axis scale instead of 0.0 0.7.

enter image description here

here code above graph.

in [90]: df out[90]:               history       lit   science    social  accuracy 2014-11-18  0.680851  0.634146  0.452381  0.595745      0.01 2014-12-10  0.680851  0.634146  0.452381  0.595745      0.01  in [91]: df.plot() out[91]: <matplotlib.axes._subplots.axessubplot @ 0x7f9f3e7c9410> 

additionally want show marker 'x' each point. example, dataframe df has 2 row want mark 'x' or 'o' each point on graph.

updated:

after applied ffisegydd's great solution, got following graph want.

in [6]: df.plot(ylim=(0,1), marker='x') 

enter image description here

pandas.dataframe.plot() return matplotlib axes object. can used modify things y-limits using ax.set_ylim().

alternatively, when call df.plot() can pass in arguments style, 1 of these arguments can ylim=(minimum_value, maximum_value), meaning don't have manually use ax.set_ylim() after plotting.

you can pass keyword-arguments passed matplotlib plotting routine, can use set marker x marker='x'.

a toy example given below, ylim have been set (0,5) , marker x in df.plot() call.

import pandas pd import matplotlib.pyplot plt  df = pd.dataframe(data={'x':[0,1,2,3,4], 'y':[0,0.5,1,1.5,2]})  ax = df.plot(ylim=(0,5), marker='x')  plt.show() 

example plot


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -