[Tutor] plotting in python
Andreas Perstinger
andreas.perstinger at gmx.net
Thu Dec 1 12:39:09 CET 2011
[Still top-posting :-( ]
On 2011-12-01 11:13, stm atoc wrote:
> Well, I did also change the line in the python script to this:
>
> plot(Conc[0],z,'r-',label='initial')
> plot(Conc[1],z,'b-',label='after 20s')
>
> to see both Conc[0] and [1].
And did it work?
> I will send the output data attaches to this email ("ourtest_out.list").
>
> I wonder if this way is fine.
I'm not sure about the policy regarding attachements on this list but I
think it would have been better to provide a link than attach it.
Anyways, I've reduced your original script, did a test run and it works
as expected (at least it shows a plot):
import numpy
import matplotlib.pyplot as pyplot
with open("ourtest_out.list", "r") as f:
z = numpy.array([float(v) for v in f.readline().split()[1:]])
a = numpy.loadtxt("ourtest_out.list", skiprows=3)
N = 100
Conc = a[1:, N+1:]
print len(Conc[0]) == len(z)
pyplot.figure()
pyplot.plot(Conc[0], z)
pyplot.show()
Do you still get an error?
Bye, Andreas
More information about the Tutor
mailing list