plotting pairs of data
hugocoolens
hugocoolens at gmail.com
Wed Dec 19 15:46:07 EST 2012
On 19 dec, 15:38, Thomas Bach <thb... at students.uni-mainz.de> wrote:
> On Wed, Dec 19, 2012 at 05:47:30AM -0800,hugocoolenswrote:
> > The data is available in Python in this format:
> > ['0.0364771 0.55569', '0.132688 0.808496', '0.232877 0.832833',
> > '0.332702 0.849128', '0.432695 0.862158']
>
> > I suppose it is possible to plot x versus y using matplotlib, maybe
> > separating the data first in two arrays, but I'm not sure whether this
> > is necessary.
>
> I think, yes it is necessary to split the data in separate
> lists/arrays. Although I find it annoying, too.
>
> In case that not only the if, but also the how is the matter of your
> question something like
>
> xs = [ float(x) for x, _ in map(str.split, l) ]
> ys = [ float(y) for _, y in map(str.split, l) ]
>
> should do the trick.
>
> Regards,
> Thomas Bach.
thanks Thomas this works nicely
hugo
More information about the Python-list
mailing list