On 24 February 2010 13:36, AG <computing.account@...> wrote:
> Hi
>
> How do I set up my matplotlib.pyplot code so that the data for the
> xaxis is plotted beginning at 1 not the default 0. To illustrate:
>
> I have a set of time trials and error probability calculations. Trials
> are x and scores are y. At present, the first trial is plotted on the
> graph at 0 which is illogical. I admit that I'm not sure exactly what I
> am looking for, but I can't see this mentioned in the docs. I just want
> the plot to begin at trial 1, not the 0; however, I don't mind if the
> xaxis has a 0 scale on it, but trials don't begin at a 0 trial, so how
> do I get around this.
>
> I've listed the basic code below:
>
> plt.plot( scores )
> plt.ylabel( "Scores" )
> plt.xlabel( "Trials" )
> plt.show()
You can explicitly specify xaxis values:
x = np.arange(len(scores)) + 1
plt.plot(x, scores)
HTH,
Angus.

AJC McMorland
Postdoctoral research fellow
Neurobiology, University of Pittsburgh
