[Tutor] plotting in python

stm atoc stm.at.oc at googlemail.com
Thu Dec 1 13:11:23 CET 2011


For previous script that I have written, I had trouble having one plot
for all data at the same time and I could see two line for Conc[0] and
Conc[1] separately. Now, even I modified Conc = a[1:, N+1:] to  Conc =
a[0:, N+1:], still one plot is created...which is pretty good and no
error!

Thank you so much,
Sue

On Thu, Dec 1, 2011 at 12:39 PM, Andreas Perstinger
<andreas.perstinger at gmx.net> wrote:
> [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