From: AG <com...@go...> - 2010-02-24 19:06:38
|
Angus McMorland wrote: > On 24 February 2010 13:36, AG <com...@go...> 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 |