Excellent thank you!! On Mon, Nov 30, 2009 at 7:03 PM, Kent Johnson <ken...@tds.net> wrote:
> On Mon, Nov 30, 2009 at 8:26 PM, Wayne Werner <waynejwer...@gmail.com> > wrote: > > > A sample of the data is always helpful, but I'll take a shot in the dark. > > If you have data like this: > > 2.31 72 > > 98 23 > > ... .... > > 34 7.32 > > And those are x y pairs you could do something like this: > > f = open('input.txt') > > #List comprehension to read all the lines as [[x1, y1], [x2, y2], ... > [xn, > > yn]] > > data = [line.split() for line in f] > > You have to convert the text strings to float somewhere, for example > data = [ map(float, line.split()) for line in f ] > > > # Reorient values as [(x1, x2,... xn), (y1, y2, ... yn)] > > data = zip(*data) > > # plot the xy vals > > pylab.scatter(data[0], data[1]) > > Or, IMO a little clearer, > x, y = zip(*data) > pylab.scatter(x, y) > > Kent >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor