## matplotlib-users

 [Matplotlib-users] Setting graph to commence at 1 on x-axis From: AG - 2010-02-24 18:36:28 ```Hi How do I set up my matplotlib.pyplot code so that the data for the x-axis 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 x-axis 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() TIA AG ```
 Re: [Matplotlib-users] Setting graph to commence at 1 on x-axis From: Angus McMorland - 2010-02-24 18:54:10 ```On 24 February 2010 13:36, AG wrote: > Hi > > How do I set up my matplotlib.pyplot code so that the data for the > x-axis 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 > x-axis 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 x-axis values: x = np.arange(len(scores)) + 1 plt.plot(x, scores) HTH, Angus. -- AJC McMorland Post-doctoral research fellow Neurobiology, University of Pittsburgh ```
 [Matplotlib-users] [SOLVED] Re: Setting graph to commence at 1 on x-axis From: AG - 2010-02-24 19:06:38 Attachments: Message as HTML ```Angus McMorland wrote: > On 24 February 2010 13:36, AG wrote: > >> Hi >> >> How do I set up my matplotlib.pyplot code so that the data for the >> x-axis 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 >> x-axis 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 x-axis values: > > x = np.arange(len(scores)) + 1 > plt.plot(x, scores) > > HTH, > > Angus. > Hi Angus Thanks for the quick reply. Once I imported numpy as np and re-ran the program that did the trick perfectly. Many thanks!! All the best AG ```