A few simple graphing questions

Hi All,

I love the graphs Igor Pro produces but am a beginner. Could I please have some assistance on the following issues:

1. Can I use the procedure window as a script? I have all of my graphing code in the procedure window, but how do I 'run it' so it produces my graph (like a script in MATLAB?) All I can see is compile.

2. How can I modify a range of points when using ModifyGraph?
I can do this:
ModifyGraph rgb(wave0[0])=(0,0,65280)
but I want to modify several wave0 points. Right now I do it by hand:
ModifyGraph rgb(wave0[0])=(0,0,65280)
ModifyGraph rgb(wave0[5])=(0,0,65280)
ModifyGraph rgb(wave0[10])=(0,0,65280)
ModifyGraph rgb(wave0[15])=(0,0,65280)

Is there a single way to do this? Something like ModifyGraph rgb(wave0[0,5,10])=(0,0,65280)

Also can it be doing with selecting a certain range? E.g. if I have 25 points, and I want points 0 to 20 in 5 step increments? In MATLAB this would be 0:5:20

Thanks for all your help

Edit:

My procedure to plot the graph is literally

#pragma rtGlobals=3 // Use modern global access method and strict wave access.
Display wave0 vs wave1
ModifyGraph mode=3,marker=19

...etc etc

Am I doing it right? Can it be used like a MATLAB script?

Thanks
The short answer is "yes". You can write a function in the procedure window that you can call to modify your graph. These functions can do graph modifications and pretty much whatever you want.

The longer answer is that to write something that's more flexible you'd need to know the window name, the trace names, point ranges, colours (how to specify them etc).

To simply do the same thing to save you typing it over and over. Put this in the procedure window:
Function DoYourThing()
    //put your code here
End


Press compile. Select the graph you want, then type in the Command Window "DoYourThing()". This should run your code on the top graph window.
Thanks srj51, that works well. I did not know you need to execute the function name in the command window. I am so used to the MATLAB way of doing things, which refers to data stores in the workspace.

Just wondering if there is a solution to my first question? To index multiple points when Modifying the graph.

Thanks
I *think* ranges for point by point modifications of traces are not possible. You might just use an explicit loop to do the job. However, you might want to have a look at the color=f(z) feature using an auxiliary wave to store the color information.
More information can be found in displayhelptopic "ModifyGraph for Traces"
HJ
You can do indexing with a specific increment. From the manual

You can specify not only a range but also a point number increment. For example:
wave0[0,98;2] = 1 // sets even numbered points in wave0 to 1
wave0[1,99;2] = -1 // sets odd numbered points in wave0 to -1
The number after the semicolon is the increment. Igor begins at the starting point number and goes up to
and including the ending point number, skipping by the increment.


Run displayhelptopic "indexing and subranges" from the command window for more detail.

I vaguely recalled this feature, but had to do a quick look up in the manual to be sure.
I don't think point ranges are possible. You can specify wave0[0,*;5] (meaning every 5th point starting from 0 going to end) in some contexts but not in ModifyGraph rgb() it seems.

An f(z) approach is a good idea.
Make/O/N=25 colorwave
colorwave=0
colorwave[0,*;5] = 1
ModifyGraph zColor(wave0)={colorwave,*,*,Rainbow,1}


Hopefully this gives you an idea.
sjr51 is correct. My solution is not applicable to the ModifyGraph command. This command syntax will only take single point values. See the "ModifyGraph (traces)" command in chapter V of the on line manual; scroll down several pages to the "Customize at Point" section.
SteveHatcher wrote:

2. How can I modify a range of points when using ModifyGraph?
I can do this:
ModifyGraph rgb(wave0[0])=(0,0,65280)
but I want to modify several wave0 points. Right now I do it by hand:
ModifyGraph rgb(wave0[0])=(0,0,65280)
ModifyGraph rgb(wave0[5])=(0,0,65280)
ModifyGraph rgb(wave0[10])=(0,0,65280)
ModifyGraph rgb(wave0[15])=(0,0,65280)

Is there a single way to do this? Something like ModifyGraph rgb(wave0[0,5,10])=(0,0,65280)


This function might answer a few of your questions.

// function to modify the rgb  colors of points on a graph
// tname - trace name to modify (on front graph!)
// wpoints - selected points to modify (as a wave)
// rgbset - rgb color values in 3 point wave

Function ColorCertainPoints(tname,wpoints,rgbset)
    string tname
    wave wpoints, rgbset

    variable ic, pnt
   
    for (ic=0;ic<numpnts(wpoints);ic+=1)
        pnt = wpoints[ic]
        ModifyGraph rgb($tname[pnt]) = (rgbset[0],rgbset[1],rgbset[2])
    endfor
   
    return 0
end


Put it in the procedure window and compile. Select the graph you want. Type the commands below in the command line.

make/N=3 rgbset = {0,0,65280}
make/N=10 ywave = p^2
make/N=3 ptocolor = {0,3,8}
display ywave
ModifyGraph mode=3
ColorCertainPoints("ywave", ptocolor, rgbset)



--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
The suggestions to use color as f(z) are correct. To read about it, copy this command, paste it into Igor's command line and press Enter:
DisplayHelpTopic "Setting Trace Properties from an Auxiliary (Z) Wave"

If you haven't done it already, be sure to select Help->Getting Started and go through at least the first half of the Guided Tour. It takes a bit of time but will save more time by introducing you to some of the quirks of Igor's operation and his way of "thinking". And you may wish to read the Graphs chapter in the manual. It will cure insomnia and also tell you just about everything you need to know about graphs.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com