Content-Type: multipart/alternative; boundary="_000_40C117BB7CCD134EB9FB61E9DA0E56BB109EEC8758HQMAIL04nvidi_" --_000_40C117BB7CCD134EB9FB61E9DA0E56BB109EEC8758HQMAIL04nvidi_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks all for the help again, after a bit trial-n-error, this is what I = did, (only 4 lines of code): x5y =3D np.loadtxt(fp) x,y =3D x5y[:, 0], x5y[:, 1:5] #plt.plot(x, y) plt.semilogy(x, y) plt.show() and the plot. Btw, I am not a SW guy as you probably can tell, but a CFD= =20(computational Fluid Dynamics) guy who happens to write code. The plo= t is a convergence history plot of an iterative algorithm. [cid:image001.png@01CB0242.4E0B4690] From: Benjamin Root [mailto:ben.root@ou.edu] Sent: Tuesday, June 01, 2010 7:24 PM To: Malte Dik Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] multiple lines Malte, You may want to look into Numpy's genfromtxt() or loadtxt() functions. T= hey will make your life so much easier for loading data from a text file.= Ben Root On Tue, Jun 1, 2010 at 6:47 PM, Malte Dik > wrote: Howard Sun > > Sorry for the newbie question, how do you plot one x with multiple ys. = In > below data, x column is followed by 5 y columns: Many thanks! > Howard > > 2 1.0000e+00 6.6232e-02 9.9392e-03 2.2992e-02 3.8111e-07 > 3 6.3664e-01 1.0269e-01 7.9107e-03 1.8254e-02 1.1391e-07 > 4 2.7590e-01 4.9783e-02 6.2644e-03 1.0943e-02 5.8480e-08 > 5 1.6550e-01 2.3269e-02 4.7482e-03 8.4312e-03 5.8239e-08 > 6 1.1590e-01 1.7234e-02 3.8567e-03 8.7010e-03 4.5506e-08 > 7 7.4337e-02 1.1662e-02 3.3756e-03 8.0889e-03 4.0900e-08 > 8 5.7775e-02 1.0917e-02 2.8980e-03 6.9654e-03 3.7520e-08 > 9 4.7310e-02 1.1869e-02 2.5929e-03 5.8326e-03 3.4745e-08 > 10 3.9591e-02 1.1301e-02 2.4691e-03 5.2749e-03 3.2126e-08 > 11 3.6517e-02 1.0755e-02 2.3121e-03 4.8631e-03 3.7942e-08 > 12 3.2872e-02 9.8306e-03 2.1692e-03 4.6281e-03 3.2358e-08 > 13 3.1235e-02 9.1704e-03 2.0419e-03 4.3928e-03 3.1479e-08 > 14 2.9528e-02 8.6926e-03 1.9364e-03 4.1360e-03 3.5639e-08 > 15 2.7895e-02 8.3080e-03 1.8475e-03 3.9015e-03 3.0486e-08 > 16 2.6440e-02 7.9610e-03 1.7776e-03 3.6790e-03 3.0307e-08 > 17 2.5259e-02 7.6345e-03 1.6984e-03 3.4743e-03 3.1805e-08 > 18 2.4064e-02 7.3267e-03 1.6341e-03 3.2848e-03 3.0188e-08 > 19 2.3171e-02 7.0284e-03 1.5821e-03 3.1098e-03 2.7565e-08 > 20 2.2317e-02 6.7322e-03 1.5247e-03 2.9475e-03 2.7009e-08 First, you take the data apart, like in: import csv, numpy # let's call your array "filecopy" d =3D csv.Sniffer().sniff(filecopy[0]) for this_one_line in csv.reader(filecopy, d): =20 header =3D this_one_line =20 break data =3D numpy.zeros((len(header), len(filecopy))) for line in csv.reader(filecopy[1:], d): =20 for n in range(len(header)): =20 data[n][linecounter] =3D float(line[n]) =20 linecounter +=3D 1 -------------------------------------------------------------------------= ---------- This email message is for the sole use of the intended recipient(s) and m= ay contain confidential information. Any unauthorized review, use, disclosure or di= stribution is prohibited. If you are not the intended recipient, please contact the= =20sender by reply email and destroy all copies of the original message. -------------------------------------------------------------------------= ---------- --_000_40C117BB7CCD134EB9FB61E9DA0E56BB109EEC8758HQMAIL04nvidi_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Thanks all for the help again, after a bit trial-n-error, = this is what I did, (only 4 lines of code):

 

x5y =3D np.loadtxt(fp)

x,y =3D x5y[:, 0], x5y[:, 1:5]

 

#plt.plot(x, y)

plt.semilogy(x, y)

plt.show()

 

and the plot.  Btw, I am not a SW guy as you probably= =20can tell, but a CFD (computational Fluid Dynamics) guy who happens to write code.&n= bsp; The plot is a convergence history plot of an iterative algorithm.

 

 

 

From: Benjamin Ro= ot [mailto:ben.root@ou.edu]
Sent: Tuesday, June 01, 2010 7:24 PM
To: Malte Dik
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] multiple lines

 

Malte,

You may want to look into Numpy's genfromtxt() or loadtxt() functions.&nb= sp; They will make your life so much easier for loading data from a text file= .

Ben Root

On Tue, Jun 1, 2010 at 6:47 PM, Malte Dik <malte.dik@web.de> wrote:

Howard Sun <hs= un@nvidia.com>

> Sorry for the ne= wbie question, how do you plot one x with multiple ys. In
> below data, x column is followed by 5 y columns: Many thanks!
> Howard
>
> 2 1.0000e+00 6.6232e-02 9.9392e-03 2.2992e-02 3.8111e-07
> 3 6.3664e-01 1.0269e-01 7.9107e-03 1.8254e-02 1.1391e-07
> 4 2.7590e-01 4.9783e-02 6.2644e-03 1.0943e-02 5.8480e-08
> 5 1.6550e-01 2.3269e-02 4.7482e-03 8.4312e-03 5.8239e-08
> 6 1.1590e-01 1.7234e-02 3.8567e-03 8.7010e-03 4.5506e-08
> 7 7.4337e-02 1.1662e-02 3.3756e-03 8.0889e-03 4.0900e-08
> 8 5.7775e-02 1.0917e-02 2.8980e-03 6.9654e-03 3.7520e-08
> 9 4.7310e-02 1.1869e-02 2.5929e-03 5.8326e-03 3.4745e-08
> 10 3.9591e-02 1.1301e-02 2.4691e-03 5.2749e-03 3.2126e-08
> 11 3.6517e-02 1.0755e-02 2.3121e-03 4.8631e-03 3.7942e-08
> 12 3.2872e-02 9.8306e-03 2.1692e-03 4.6281e-03 3.2358e-08
> 13 3.1235e-02 9.1704e-03 2.0419e-03 4.3928e-03 3.1479e-08
> 14 2.9528e-02 8.6926e-03 1.9364e-03 4.1360e-03 3.5639e-08
> 15 2.7895e-02 8.3080e-03 1.8475e-03 3.9015e-03 3.0486e-08
> 16 2.6440e-02 7.9610e-03 1.7776e-03 3.6790e-03 3.0307e-08
> 17 2.5259e-02 7.6345e-03 1.6984e-03 3.4743e-03 3.1805e-08
> 18 2.4064e-02 7.3267e-03 1.6341e-03 3.2848e-03 3.0188e-08
> 19 2.3171e-02 7.0284e-03 1.5821e-03 3.1098e-03 2.7565e-08
> 20 2.2317e-02 6.7322e-03 1.5247e-03 2.9475e-03 2.7009e-08

First, you take the d= ata apart, like in:

import csv, numpy

# let's call your array "filecopy"

d =3D csv.Sniffer().sniff(filecopy[0])

for this_one_line in csv.reader(filecopy, d):
       header =3D this_one_line
       break

data =3D numpy.zeros((len(header), len(filecopy)))

for line in csv.reader(filecopy[1:], d):
       for n in range(len(header)):
           data[n][linecounter] =3D float(l= ine[n])
       linecounter +=3D 1


This email message is for the sole use of the intended recipient(s) = and may=20 contain confidential information.  Any unauthorized review, use, dis= closure=20 or distribution is prohibited.  If you are not the intended recipien= t,=20 please contact the sender by reply email and destroy all copies of the or= iginal=20 message.

--_000_40C117BB7CCD134EB9FB61E9DA0E56BB109EEC8758HQMAIL04nvidi_--