Using a Macro to make a number of graphs again for a different subject - beyond the graph style macro

Hello:

I am working on graphing my dissertation data, and it involves a whole lot of graphs. Basically, I need to make 21 graphs for each of 30 subjects. I figured out how to use the graph style macro to make all the graphs look the same, but what that doesn't do for me is add the legend/textbox, make the graph, or save the data. My data are basically laid out as such:

S1_01M S1_02M S1_03M S1-04M...S1_21M S1_01MM S1_02MM S1_03MM...S1_21MM
1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3

I have 30 sets of these tables; where the data are different and S1 changes to S2, S3....S30. I basically graph 01M with 01MM for all of them (using the graph style macro), and then I need to go in and add the legend and a textbox with contrast (01, 02, 03) and then save. Is there a way to automate it all, so I can just load in the data and then execute a macro that will make all 21 graphs (with the correct columns even though they have different names for each subject), add the legend and textbox , and save to that subject's folder. Even if I had to do the saving manually, having a macro that would run and make all 21 graphs would be great.

My only thought was using the window level macro, but I am not sure that would pull the correct columns into the graph since each time they will have different names. I also didn't know if it would remember the names I gave the textboxes so the contrast would match up correctly. Finally, using one was a little confusing to me.

I hope what I am after is clear. I keep looking for something like an Excel macro where I can just record my keystrokes and then it will do it all again, however I don't see a place to record a macro like that.

Thanks for any help you can give me!!!!

-Jen
What you want is certainly doable in a number of different ways. Here is how I might start. Suppose each experiment has a different subject, and the data are in a folder called "rawdata". Suppose also, the files have the naming convention that you use. Here is an outline of a code that I would put in a procedure file.

Function GraphtheData()

    // set the data folder locations
   
    DFREF rdf = root:rawdata
    cdf = GetDataFolderDFR()
   
    // local variables and strings
   
    variable ic, nws
    string theList, theOneY, theOneX, theTitle
   
    // go to the raw data folder
   
    SetDataFolder rdf
   
    // find the waves
   
    theList = WaveList("S*_M",";","")
    nws = ItemsInList(theList)
   
    // operate on the waves in sequence
   
    for (ic=0;ic<nws;ic+=1)
        display
        theOneY = StringFromList(ic,theList)
        theOneX = theOneY + "M"
        theTitle = "Plot of " + theOneY
        appendtograph $theOneY vs $theOneX as theTitle     
   
        // put the graph changes to the graph style here
       
       
        // end of changes to graph style
         
    endfor
   
    // return to the starting data folder
   
    SetDataFolder cdf
   
    return 0

end


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
This sounds like you want to write a function that is creating your graphs.
As a starting point you might want to "Create Window Macro" (this would be the X-macro recorder -- found in window control [ctrl-y] next to Window Name), view the local procedure window (press ctrl-m), and try to understand what is going on in that procedure using the online help for the individual commands. In case you use several experiment files, you will need to move this function to a global procedure file.
Once you are familiar with this code, you can alter it to accept a parameter which defines the data set(s) to be used. Have a look at the manual for parameters in functions and a close look on the $-operator.
Have a look at the programming chapter in the manual.
The experiment can be saved using the 'SaveExperiment' command.
The command used to export the figures is logged in the history. You can probably reuse this code fragment.

HJ
Execute this for pertinent documentation:
DisplayHelpTopic "Loading Waves Using Igor Procedures"