Thanks for all information/websites and advice. Yes the graph is
exactly like the one you mentioned. Also, I would like to have them in
one not two, but I think since the dimension of the x and y are not
same, I have no choice.

 What I like to do now is comparing 2 (later 3 or more) different sets
of data, e.g. comparison among Conc[1] with sets....

I have changed the script like this:

with open("ourtest_out.list", "r") as f:
   z = numpy.array([float(v) for v in f.readline().split()[1:]])

a1 = numpy.loadtxt("ourtest_out1.list", skiprows=3)
a2 = numpy.loadtxt("ourtest_out2.list", skiprows=3)
a3 = numpy.loadtxt("ourtest_out3.list", skiprows=3)

N = 100

Conc1 = a1[0:, N+1:] #base case
Conc2 = a2[0:, N+1:] # Ydw=0.1
Conc3 = a3[0:, N+1:] # nuh=0.01
lw = 2.0 #linewidth
dpi = 96
figure(figsize=(10,6),dpi=dpi)

pyplot.subplot(111)
pyplot.plot(Conc1[1], z)
pyplot.plot(Conc2[1], z)
pyplot.plot(Conc3[1], z)
pyplot.xlim(0,1)

plt.xlabel('Conc')
plt.ylabel('z')

pyplot.grid(True)
show()
savefig('Conc.png')
close()

This can give me the comparison in one graph, I suppose.
Now, first I like to know if this is a fine/logical script. otherwise
I would like to know about probably a better way to write it with less
lines!
and second, when I do plot, each grid between x or y axis, has a
thickness of 0.2. what I like do is to change it to 0.1 grid . So, I
couldn't find it through matplotlib website (at least with my
searching. Would it be possible helping me about?  I am  new at python
and a beginner and I do have learn while I work with it...

Thanks in advance,
Sue


On Thu, Dec 1, 2011 at 6:25 PM, Andreas Perstinger
<andreas.perstin...@gmx.net> wrote:
> On 2011-12-01 14:30, stm atoc wrote:
>>
>> With your help, I have a good script from the previous discussion:
>>
>> **********
>> from pylab import *
>
>
> Have you used MATLAB before and are used to its syntax? In general "star
> imports" (from xxx import *) are a bad practice and IMHO should be avoided.
>
>
>> import numpy
>> import matplotlib.pyplot as pyplot
>> import matplotlib.mlab as mlab
>
>
> These imports are unnecessary if you use the first line because "pylab"
> imports everything from "numpy" and "matplotlib" into a single namespace. So
> either use just the first line (not recommended) or the following line
> (recommended).
>
> See also
> http://matplotlib.sourceforge.net/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related
> and
> http://matplotlib.sourceforge.net/faq/usage_faq.html#coding-styles
>
> BTW: Why do you import "mlab" when you don't use it?
>
>
>> 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[0:, N+1:]
>> print len(Conc[0]) == len(z)
>
>
> This line was just for testing. You can delete it without any consequences.
>
>
>
>> figure()
>>
>> pyplot.plot(Conc[0],z,'r-',label='initial')
>> pyplot.plot(Conc[1],z,'b-',label='after 20s')
>>
>> show()
>
>
> Isn't that what you want? You are plotting all your data in one graph. There
> is a straight red line on the left side and a falling blue line from left to
> right.
>
>
>> *********
>>
>> I have tried to make subplot for this case as follows:
>>
>> pyplot.subplot(111)
>> pyplot.plot(Conc[0],z,'r-',label='initial')
>> pyplot.plot(Conc[1],z,'b-',label='after 20s')
>
>
> Here you are creating a subplot with 1 plot each row and 1 plot each column,
> in other words you do the same as above (creating just 1 plot). If you want
> to have for example 4 plots in the same window with 2 each row and 2 each
> column you have to use
>
> pyplot.subplot(221)
>
> After plotting all the data in this first "axes" you have to switch to the
> next one:
>
> pyplot.subplot(222)
>
> Have you already read the matplotlib-tutorial:
> http://matplotlib.sourceforge.net/users/pyplot_tutorial.html
>
>
>> However, I am not sure how to add new data over this to make a graph
>> including both new and old data simultaneously.
>
>
> As I've said before: You are already plotting all data in one graph.
> Don't you get two different lines?
>
> Bye, Andreas
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to