Angus McMorland wrote:
On 24 February 2010 13:36, AG <computing.acco...@googlemail.com> 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
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to