Hi Elaina,

> Hi everyone,
>    I am trying to set up a code to do some plotting and before I get too far 
> I wanted to ask some structure questions.  Basically I want to tell python to 
> read 2 datasets, plot them on the same scale on the same x-y axis , read a 
> third dataset and match the name from the first dataset, then label certain 
> values from the third... complicating matters is that all these data are part 
> of much, much larger sets in seperate files, the paths look like:
> pathway1/namered.dat
> pathway2/nameblue.dat
> matchingfile.txt
> 
> so I do fopen on the matchingfile, read it with asciitable, and then I have a 
> column in that file called 'name' and a column called 'M', I sort the file, 
> return a subset that is interesting, and get name1, name2, etc for every 
> subset.  I want to make a plot that looks like:
> 
> plot pathway1/namered.dat and pathway2/nameblue.dat with label 'M' for every 
> value in the subset name1, each row[i] I need to assign to a seperate window 
> so that I get a multiplot with a shared x-axis, and stacking my plots up the 
> y-axis.  I do have multiplot working and I know how to plot 'M' for each 
> subset.
> 
> The conceptual trouble has come in, how do I match 'name' variable of my 
> subset 'name1' with the plot I want to do for pathway1/namered.dat and 
> pathway2/nameblue.dat... the key feature that is the same is the 'name' 
> variable, but in one instance I have to match the 'name'+'red.dat' and in the 
> other the 'name'+'blue.dat'

It's not 100% clear to me what you precisely want to do, but here are a few 
possibilites:

- use a dictionary. Assign each dataset to a dictionary with the name as the 
key (or the name + color). Eg, dataset['name1red'], dataset['name1blue'], 
dataset['name2red'] etc. Each value in this dictionary is a dataset read by 
asciitable. 
  the (big) disadvantage is that you would read every single *.dat file 
beforehand
- simply fopen the files with the filename deduced from the name. So, in a 
loop, that would be something like 
   for name in subset_names:
      with fopen(name + 'red.dat') as datafile:
          # read data and plot
      with fopen(name + 'blue.dat') as datafile:
          # read data and plot

But perhaps I misunderstand your problem. I can't really tell if the problem is 
in opening the selected data files, or plotting them, or creating the labels 
for the plot.
This may actually be where some code comes in handy. Provided the plotting 
isn't the problem, you could make a very simple Python script that shows the 
concept and how you attempt to solve it. The simpler the script, the better 
probably the implementation, so even make such a simple script is incredibly 
useful. (Any example data sets of, say, just 2 lines each can also help with 
that.)
>From that, the problem may become clearer and we can help you improving the 
>script.

Of course, someone else may actually understand the problem properly and has a 
better suggestion.

Cheers,

  Evert

(yes, small world ;-)


> Any ideas would be appreciated, thanks!
> ~Elaina Hyde
> 
> -- 
> PhD Candidate
> Department of Physics and Astronomy
> Faculty of Science
> Macquarie University
> North Ryde, NSW 2109, Australia
> _______________________________________________
> 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