automatically plotting different sets of data

Hello,

I am afraid that I know the answer to the question: use python

But my problem is that I do not really know python. I just started and
I can do some nice plots with matplotlib but I don't really know
python.

I am now running into a snag. I have different directories with
different number of data files

Directory 1 ---> data1.dat data2.dat data3.dat data4.dat data5.dat
Directory 2 ---> data1.dat data2.dat data3.dat

The number of files is huge, I do not want to run this one by one per hand.

I am trying to do this with a shell script which actually prepares the
data files but I do not know how to tell matplotlib from the shell
script that the number of files is different and that it should use
different colours for different files.

I can explain this in much more detail if needed, but I wanted to hear
a first impression.

thanks,

Pau

PS: I thought I would probably give a better example

In a directory I have these files:

2537.dat
5043.dat
5075.dat
7581.dat
1.009e+04.dat
1.551e+04.dat
1.805e+04.dat
2.056e+04.dat
4.955e+04.dat
5.209e+04.dat
5.459e+04.dat
5.462e+04.dat
1.445e+05.dat
1.47e+05.dat
5.016e+05.dat
5.041e+05.dat
5.067e+05.dat
5.171e+05.dat
5.196e+05.dat
5.511e+05.dat
5.537e+05.dat
5.562e+05.dat
8.842e+05.dat
1.465e+06.dat

I would like to plot them with matplotlib like this:

···

-----------------------------------------------------------
X = cluster[:, 1] # Column 2
Y = cluster[:, 2] # Column 3
M = cluster[:, 4] # Column 5
Radius = log(M)

ylabel ('Y (pc)', size=18)

scatter(X, Y, s=Radius,\
        marker='o', color='red',\
        edgecolors='black',\
        alpha=0.9,antialiased=True)

xlabel ('X (pc)', size=18)
-----------------------------------------------------------

where

"cluster" runs from the first data file to the last one and
"color" changes from one data file to the next one

The goal is to have all the data files plotted in a single graph

How could I do this?

Thanks a lot

P.

On 3 May 2011 20:37, Pau <vim.unix@...982...> wrote:

Hello,

I am afraid that I know the answer to the question: use python

But my problem is that I do not really know python. I just started and
I can do some nice plots with matplotlib but I don't really know
python.

I am now running into a snag. I have different directories with
different number of data files

Directory 1 ---> data1.dat data2.dat data3.dat data4.dat data5.dat
Directory 2 ---> data1.dat data2.dat data3.dat

The number of files is huge, I do not want to run this one by one per hand.

I am trying to do this with a shell script which actually prepares the
data files but I do not know how to tell matplotlib from the shell
script that the number of files is different and that it should use
different colours for different files.

I can explain this in much more detail if needed, but I wanted to hear
a first impression.

thanks,

Pau

would it be easier to have all data in a single file and then tell
matplotlib to plot different parts of that file?

The file would look like:

.
.
.
  13.0576 -66.6586 -9.6419 34.1672 1.445e+05 4962
  13.0576 -55.4192 44.0864 16.7687 1.445e+05 4963
  13.0576 65.0328 -38.8888 -215.3602 1.445e+05 4964
  13.0576 -110.7375 -0.1741 -91.9251 5.459e+04 4512
.
.
.

The fifth column is what defines the transition between a file and the next one

How can I tell matplotlib to plot those data first with a certain
color and then the next data with a different color?

···

On 3 May 2011 21:38, Pau <vim.unix@...982...> wrote:

PS: I thought I would probably give a better example

In a directory I have these files:

2537.dat
5043.dat
5075.dat
7581.dat
1.009e+04.dat
1.551e+04.dat
1.805e+04.dat
2.056e+04.dat
4.955e+04.dat
5.209e+04.dat
5.459e+04.dat
5.462e+04.dat
1.445e+05.dat
1.47e+05.dat
5.016e+05.dat
5.041e+05.dat
5.067e+05.dat
5.171e+05.dat
5.196e+05.dat
5.511e+05.dat
5.537e+05.dat
5.562e+05.dat
8.842e+05.dat
1.465e+06.dat

I would like to plot them with matplotlib like this:

-----------------------------------------------------------
X = cluster[:, 1] # Column 2
Y = cluster[:, 2] # Column 3
M = cluster[:, 4] # Column 5
Radius = log(M)

ylabel ('Y (pc)', size=18)

scatter(X, Y, s=Radius,\
marker='o', color='red',\
edgecolors='black',\
alpha=0.9,antialiased=True)

xlabel ('X (pc)', size=18)
-----------------------------------------------------------

where

"cluster" runs from the first data file to the last one and
"color" changes from one data file to the next one

The goal is to have all the data files plotted in a single graph

How could I do this?

Thanks a lot

P.

On 3 May 2011 20:37, Pau <vim.unix@...982...> wrote:

Hello,

I am afraid that I know the answer to the question: use python

But my problem is that I do not really know python. I just started and
I can do some nice plots with matplotlib but I don't really know
python.

I am now running into a snag. I have different directories with
different number of data files

Directory 1 ---> data1.dat data2.dat data3.dat data4.dat data5.dat
Directory 2 ---> data1.dat data2.dat data3.dat

The number of files is huge, I do not want to run this one by one per hand.

I am trying to do this with a shell script which actually prepares the
data files but I do not know how to tell matplotlib from the shell
script that the number of files is different and that it should use
different colours for different files.

I can explain this in much more detail if needed, but I wanted to hear
a first impression.

thanks,

Pau

Fortunately, the documentation is excellent:

hth,
Alan Isaac

···

On 5/3/2011 2:37 PM, Pau wrote:

I am afraid that I know the answer to the question: use python

But my problem is that I do not really know python.

From: Pau [mailto:vim.unix@…982…]

PS: I thought I would probably give a better example

The goal is to have all the data files plotted in a single graph

import glob

for filename in glob.glob('*.dat'):
    if 'e' in set(filename): #or whatever
        #do something for files that have an 'e' in their name
    else:
        #do something else
    loadtxt(filename) #yada, yada, yada
    scatter() #etc.

THANKS!!

I am not a native speaker and sometimes I find it very hard to find a
keyword to look for...

that tip was excellent, thank you a lot

···

On 3 May 2011 22:27, Buchholz, Greg <gbuchholz@...3595...> wrote:

From: Pau [mailto:vim.unix@…982…]

PS: I thought I would probably give a better example

The goal is to have all the data files plotted in a single graph

import glob

for filename in glob.glob('*.dat'):
if 'e' in set(filename): #or whatever
#do something for files that have an 'e' in their name
else:
#do something else
loadtxt(filename) #yada, yada, yada
scatter() #etc.