[newbie] plotting pairs of data
thbach at students.uni-mainz.de
Wed Dec 19 15:38:30 CET 2012
On Wed, Dec 19, 2012 at 05:47:30AM -0800, hugocoolens wrote:
> 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.
More information about the Python-list