Igor Programming

0. Traps beginners often get caught in  

1. Functions and Macros

Macro and function both returns some result using the inputs. 

Macro can be used through the Igor macro menu. 

In the case of function, you can use them in macros as a "subroutine", or you can also use them independently from the command window. 

Coding Conventions made by thomas_braun 

https://www.wavemetrics.com/project/CodingConventions

"Coding Conventions" in by thomas_braun translated into Japanese by ryotako.

https://ryotako.hatenablog.com/entry/2017/02/14/220542

Practical differences:

Example:

Macro Wave2Dto1Dnew(wav2)                               // argument wav2 is a String parameter

Variable Rownum, Colnum

Variable, xmin, xdelta

String wave1D, Thetast

String wav2                                          // wav2 is defined as a String parameter   

Prompt wav2, "2D wave", popup , WaveList("*",";","") // insert a text contents to the String parameter wav2 

Silent 1;PauseUpdate

//

if( WaveDims($wav2) != 2) //String parameter wav2 is converted to a Wave reference parameter $wav2 by using $ 

     Abort wav2+" is not a two-dimensional wave."

endif

//

Rownum = DimSize ($wav2, 0) //String parameter wav2 is converted to a Wave reference parameter $wav2 by $        

Colnum = DimSize ($wav2, 1)   

xmin = DimOffset($wav2,1)

xdelta = DimDelta($wav2,1)

Make /N= (Rownum,Colnum) wav4 //wav4 is a wave reference parameter created here.

wav4 = $wav2                 //String parameter wav2 is converted to a Wave reference parameter $wav2 by $

i = 0

Do

     Theta = xmin + xdelta * i

     Thetast = num2str ( Theta)

    ist =  num2str(i)

wave1D = wav2 + "_" + ist + "_" + thetast  //wave1D is a string parameter

Make /N=(Rownum) $wave1D        // wave1D is converted to a wave reference parameter $wave1D by using $

$wave1D[] = wav4[p][i]    //a wave reference parameter $wave1D is used for data manipulation

       i += 1

While (i <Colnum)

.......



Function XYplotsfrom2_2Dwaves(wave1rho,wave2z)  // argument wave1rho and wave2z are Wave reference parameters

   wave wave1rho,wave2z    //you can use Wave reference parameter declaration only in functions.

   Variable zmin, zmax, i

   string flagName, DFolder, DestDF, ist, Wave1D

   string w1rho

   //

  w1rho = nameOfWave(wave1rho)  //extract string from Wave reference parameters

if( WaveDims(wave1rho) != 2)  //Wave reference parameter

Abort "rho file is not a two-dimensional wave."

  endif

if( WaveDims(wave2z) != 2)  //Wave reference parameter

Abort "z file is not a two-dimensional wave."

  endif

  //

  Variable destwvp=DimSize(wave1rho,0)  //Wave reference parameter

  Variable destwvq=DimSize(wave1rho,1)

  Variable destscp=DimSize(wave2z,0)

  Variable destscq=DimSize(wave2z,1)

  String   savDF = GetDataFolder(1)

  //

print savDF

DFolder = "XY" + w1rho    //string

NewDataFolder /O $DFolder  //string is converted to Data folder reference by using $

DestDF = savDF + DFolder +":"

  print DestDF

  Display

  //

  i = 0

Do

     ist = num2str(i)

     //

Wave1D = w1rho + "_" + ist   //string

Make /O/N=(destwvp) $wave1D //string is converted to wave reference by using $

    Wave xy1D = $wave1D  //a wave reference using $ is inserted to wave reference parameter without $

    //            //above roundabout expression is necessary only in functions because you can not 

                   //execute $wave1D[] = wave1rho[p][i], but you can execute xy1D[] = wave1rho[p][i].

zmin=wave2z[0][i]

zmax=wave2z[destscp-1][i]

SetScale /I  x, zmin, zmax, $wave1D

//                      //For some reason, you can NOT execute $wave1D[] = wave1rho[p][i] in functions, unlike macros.

     xy1D[] = wave1rho[p][i] //a wave reference parameter without $ is used for data manipulation.  

     appendToGraph xy1D      //a wave reference parameter without $ is used for plot.

.....



2. Data Loading

(1) To load 2D text wave to Igor as matrix

Data>Load waves>Load waves. Check "load columns into matrix" check box. File type should be "General text".

(2) To load a data in a macro or function

In the following example,  a Igor binary wave ametrine.ibw in C:\Program Files\WaveMetrics\Igor Pro 8 Folder\Color Tables\EPFL is loaded.

string fullpath = SpecialDirPath("Igor Application", 0, 0, 0)

string EPFLpath = fullpath + "Color Tables:EPFL:"

Newpath/O pname, EPFLpath

LoadWave/O/M/P=pname/B="N=ametrine;" "ametrine.ibw"



3. Wave and Folder handling

(1) To rename selected files in the Data browser by adding a pre and a suffix to the original wave names

https://www.wavemetrics.com/code-snippet/batch-rename-selected-wave-and-folder-names

Download QuickRename.ipf and open it from Igor, and then compile it.

To use it, select waves and data folders at the data browser, and then type QuickRenameWrapper() at the procedure window and press enter key.

You will see "replace part of the Name" popup window. To add prefix A to all the waves, for example, put "pre" at the first replace this box, and put "A" in the WIth this box.

Choose one of the three choices at the keep original? box according to your policy. The press continue button.

(2) Wave and Data folder handling

To specify waves and data folders, there are three methods. (a) using the literal wave name, (b) using a string which contains the literal wave name, and (c) using the wave reference. 


4. Data manipulation

(1) Access to elements of a wave

Specify a element of a wave using index:

   wave[p]                                    

Specify a element of a wave using x (scaling):

   wave(p)                                           

Specify values of a part of a wave:

   wave0[0,15]=wave2                           

input a part of a wave to another wave: 

   wave0[15,25]=wave2[p-15,p-25]

(Here, p is the index of wave0. In the above case, the value of wave2[0] goes to wave0[15], which corresponds to the case of p=15.)


(2) Expanding a 1D  wave into a 2D matrix wave ( (1D, 1D, 1D, 1D)).

           wave2d=wave1d[p]

(3) Rearranging elements in a 2D wave upside-down (ref. https://www.wavemetrics.com/node/20889). 

        In the case the 2D wave is in  the data folder root:E_G_Jp:,  and the name is viridis1,  and has 134 rows, and the destination wave is viridis1rev,

root:E_G_Jp:viridis1rev = root:E_G_Jp:viridis1[134-p][q]

(4) 4-fold symmetric operation

Suppose you have a wave $wav(Rownum, Colnum) which is a part (the 4th quadrant) of a whole wave. 

To make the whole wave $wavedest(Rownum*2-1,Colnum*2-1) from the partial wave by the 4-fold symmetric operation, you can use the following data manipulation. 

  Make/O/N=(Rownum*2-1,Colnum*2-1) $wavedest

  $wavedest[0,Rownum-2][0,Colnum-2]= $wav2[Rownum-1-p][Colnum-1-q] //2nd quadrant

  $wavedest[Rownum-1,Rownum*2-1][0,Colnum-2]= $wav2[p-(Rownum-1)][Colnum-1-q] //3rd quadrant

  $wavedest[0,Rownum-1][Colnum-1,Colnum*2-1]= $wav2[Rownum-1-p][q-(Colnum-1)]//1st quadrant

  $wavedest[Rownum-1,Rownum*2-1][Colnum-1,Colnum*2-1]= $wav2[p-(Rownum-1)][q-(Colnum-1)]//4th quadrant

(5) Matrix to XYZ  data

 Open the procedure file "MatrixToXYZ.ipf" in C:\Program Files\WaveMetrics\Igor Pro 8 Folder\WaveMetrics Procedures\Data Manipulation.

Input following two commands at the command window.

Execute/P "INSERTINCLUDE <MatrixToXYZ>"

Execute/P "COMPILEPROCEDURES "

Choose MatrixToXYZ from the macro menu, and input the matrix wave name, base name of the  output wave and so on, and then press "Continue".  You will find three 1D waves (base_nameX, base_nameY and base_nameZ) in the current folder.

If you want to make XYZ triplet wave, Choose MatrixToXYZtriplet from the macro menu. The output is a 3 columned 2D wave with the name "base_name XYZ" .

(6) Making a matrix of (m, n) to (k, l) using imageinterpolate

 ref.: https://www.wavemetrics.com/forum/general/interpolating-across-nans-2-d-matrix

 Open the  "MatrixToXYZ.ipf" procedure file using the above method.

 Suppose the initial matrix is V1.

 Execute the  MatrixToXYZtriplet macro from the maro menu. (Be aware it is not MatrixToXYZ.) 

 The source file name is V1, and the dest wave name is up to you (V1triplet here).  You should fill the dest wave name such as "dest_wave".  Don't forget using "".

Do the image interpolate from the command window.

ImageInterpolate/RESL={k,l}/I=2 Voronoi, V1triplet 


{k,l} is the row and column numbers of the destination matrix you want to have in the end. 

Reverse the triplet to matrix using XYZ triplet to Matrix in the macro menu. To use the macro, you need to specify the source and the dest wave names, the dimensions of the dest wave (k and l), min and max values of x and y scalings of the dest wave. 

(7) Rotating a image by a specified angle

Choose the image graph window to rotate, and select image->rotate image, and specify the amount of the rotation angle. By "save image" button, you can save the created wave under a name you specify. 

If the source 2D wave is not square, the rotated image will be distorted. If you want to make the source 2D wave to square, use the above method ((6) Making a matrix of (m,n) to (k,l) using imageinterpolate).

 (8) Obtaining a projection of a 2D matrix wave

Projection along x direction can be obtained by using ImageTransform. 

ImageTransform/METH=3 xProjection sourcewavename

/METH=3 is for min value. /METH=1 is for max value. yProjection and Xprojection are also available. The result is stored in a wave "M_xProjection".

(9) Matrix Transpose for 3D matrix

#For2D matrix, just use MAtrixTranspose function; ex. MatrixTranspose your2Dwave

<From Igor manual>  

transposeVol

Transposes a 3D wave. The transposed wave is stored in M_VolumeTranspose. The /O flag does not apply. The operation supports the following 5 transpose modes which are specified using the /G flag:

mode equivalent command

1 M_VolumeTranspose=imageMatrix [p][r][q]

2 M_VolumeTranspose=imageMatrix [r][p][q]

3 M_VolumeTranspose=imageMatrix [r][q][p]

4 M_VolumeTranspose=imageMatrix [q][r][p]

5 M_VolumeTranspose=imageMatrix [q][p][r]

ex. ImageTransform /G=3 transposeVol yourMatrix 

ref.:https://www.wavemetrics.com/forum/general/rotate-3d-wave

(10) make a wave having x-scaling values of a source wave

X-scaling can be extracted using "wave =x" command. To avoid the overwriting, duplicate the source wave at first, then do "=x". 

ex.. The source wave is 2D wave "V1". 

duplicate V1 V1x

Redimension/N=(-1,1) V1x

•V1x = x




5. Coloring Graphs and Images

(1) Colorize surface plots using non-built-in color table waves. 

You can colorize the surface using a fixed color or built-in color tables. To give special coloring to a 3D surface other than the fixed colors or the built-in color tables, you need to make your own color wave for the data. If the dimension of the original 2D matrix data is m x n, then the dimension of the color wave should be m x n x 4.  The 4 layers are for r, g, b and alpha for transparency. (If you don't want to specify the transparency level, the  color wave dimension can be m x n x 3.) 

 Let CW(i, j, k) the color wave. The row i and column j corresponds to the row and column of the original 2D wave. The layer k at i-th row and j-th column corresponds to the r, g, b and alpha components of the RGB color for the (i, j) pixel of the 2D data wave.  For example,  if you want to assign a RGB color (r, g. b) to a pixel at (a, b) in the original 2D matrix data, the color wave CW(i, j, k) should have values  CW(a, b, 0) = r,  CW(a, b, 1) = g, CW(a, b, 2) = b . Additionally, the transparency factor alpha is stored at CW(a, b, 3) as CW(a, b, 3) = alpha.  The color wave should be made  for each data and for each color scale. This can be done using a homemade function "snt_makecolorwave_manrange"  in our group. The r, g, b, alpha values should be between 0 and 1. (r, g, b) = (0, 0, 0) is for white, and (r, g, b) = (1, 1, 1) is for black. alpha = 1 corresponds to opaque, and alpha =0 means transparent. 

(4) Colorize traces using color waves.

To colorize a trace of a wave wave0(m),  you need to prepare mx3 or mx4 matrix. The first three columns should correspond to the r, g, b values of the color, and the last column is for  the transparency level alpha. The r, g, b, and alpha values are between 0 to 65535.  To select the color wave, go to "Modify Trace Appearance" window, and select f(z) at the color value.  Press the f(z) button, and set the color mode "Three or Four Column Color Wave".  And then, select the color wave using the pull tab. 

(5) Differently colorize traces in a graph using color tables.

Original code is here:     https://www.wavemetrics.com/forum/general/different-colors-different-waves

Select the target graph window, and then go to the command window to execute the following function by typing the function name.

#pragma rtGlobals=3 // Use modern global access method and strict wave access.

function setcolorfire()       //S. N. Takeda 2020.03.11

   string trl=tracenamelist("",";",1), item

   variable items=itemsinlist(trl), i

   variable ink=160/(items-1)

   colortab2wave yellowHot256

   wave/i/u M_colors

   for(i=0;i<items;i+=1)

       item=stringfromlist(i,trl)

       ModifyGraph rgb($item)=(M_colors[50+i*ink][0],M_colors[50+i*ink][1],M_colors[50+i*ink][2])

   endfor

   killwaves/z M_colors

end


The above example uses yellowHot256. You can change the color tables to your favorite one. The information on the Igor built-in color table is in the Igor Pro manual, at the section of  "Color Table Details" in Chapter II-15 — Image Plots. If you want to reverse the order of the color, you can use the following function.


#pragma rtGlobals=3 // Use modern global access method and strict wave access.

function setcolorfire_rev()     

   string trl=tracenamelist("",";",1), item

   variable items=itemsinlist(trl), i

   variable ink=180/(items-1)

  

   colortab2wave yellowHot256

   wave/i/u M_colors

  

   for(i=0;i<=items;i+=1)

       item=stringfromlist(items-i,trl)

       ModifyGraph rgb($item)=(M_colors[30+i*ink][0],M_colors[30+i*ink][1],M_colors[30+i*ink][2]) 

   endfor

  

   killwaves/z M_colors

end


(6) Colorize a path plot using color waves.

To colorize path plot using color wave, you need to prepare a color wave with different size depending on the type of path plot. 

Path plot itself uses XYZ wave. Each row specifies a point. Suppose the number of row of the XYZ wave is M.  Then the size of the color wave should be

       To make (Mx3, 4) or (Mx5, 4) color wave, you can use interpolate2 command.

       The following is an example. 

Suppose we have the color wave path_color_wave(351, 4) .  path_color_wavex3(1053,4) is the destination wave.

make/N=(351,1)/D path_color_waver, path_color_waveg, path_color_waveb, path_color_wavea //1D waves for rgba

path_color_waver[]=path_color_wave[p][0]

path_color_waveg[]=path_color_wave[p][1]

path_color_waveb[]=path_color_wave[p][2]

path_color_wavea[]=path_color_wave[p][3]

Interpolate2/N=(3*351) /Y=path_color_waverx3 path_color_waver

Interpolate2/N=(3*351) /Y=path_color_wavegx3 path_color_waveg

Interpolate2/N=(3*351) /Y=path_color_wavebx3 path_color_waveb

Interpolate2/N=(3*351) /Y=path_color_waveax3 path_color_wavea

Make/N=(1053,4)/D path_color_wavex3

path_color_wavex3[][0]=path_color_waverx3[p]

path_color_wavex3[][1]=path_color_wavegx3[p]

path_color_wavex3[][2]=path_color_wavebx3[p]

path_color_wavex3[][3]=path_color_waveax3[p]

(7) Colorize the curves according to the values each wave has. 

Suppose you have several 1D waves, and each wave is related to a value. If you want to colorize the traces according to the values, you can use the following procedure.


#pragma rtGlobals=3 // Use modern global access method and strict wave access.

//S. N. Takeda 2023.06.23 Before execute this, you need to load a non-built color table from

//C:\Program Files\WaveMetrics\Igor Pro 8 Folder\Color Tables

//In this macro, the coloring is determined by an external wave valuewv.(So you have to prepare it.)

//The order of the trace in the graph and the order of the reference value in the wave valuewv should be the same.


Macro set_tracecolor_byvalue(valuewv, colwv)          

String valuewv, colwv

Prompt valuewv, "value wave", popup , WaveList("*",";","")

Prompt colwv, "color wave", popup , WaveList("*",";","")

Variable numRowscltbl

if( WaveDims($valuewv) != 1)

Abort valuewv+" is not a one-dimensional wave."

endif


if( WaveDims($colwv) != 2)

Abort colwv+" is not a two-dimensional wave."

endif

print "value wave: " + valuewv + "; color wave: " + colwv

  

  string trl=tracenamelist("",";",1), item

  variable items=itemsinlist(trl), i     // number of traces in the graph

  //Print trl

  //print items


   Duplicate/O $valuewv,scaledWave

  

numRowscltbl= DimSize($colwv,0)-2

Variable theMin=WaveMin($valuewv)

Variable theMax=WaveMax($valuewv)

Variable nor=numRowscltbl/(theMax-theMin)


MatrixOP/O scaledWave=-1* nor*(scaledWave-theMax)  //MatrixOP automatically create the waveDim


   i=0

  

   Do

       item = stringfromlist(i,trl)

       print item

       ModifyGraph rgb($item)=($colwv[scaledWave[items-i-1]][0],$colwv[scaledWave[items-i-1]][1],$colwv[scaledWave[items-i-1]][2])

       i+=1

   While (i < items)

end



7. Graphing


(1) Reorder traces reversely

The order of the traces in a graph matters when you set the trace mode to "fill to next", for example. To reverse the trace ordering, you should get 

Function ReverseSorting() 

wrote by Jim at

https://www.wavemetrics.com/node/20603

I often use this after I import XPS spectra from KolXPD.

(2) Set the graph appearance to a fixed style

Make a graph in a style you like through "modify graph" panel, "modify axis"panel, and "modify trace appearance"panel. Copy the operation commands appeared at the procedure window, and paste them on a notebook (To get a notebook, Windows->New->notebook). From the next time, you can copy and paste the commands to the procedure window.

Here is an example:

ModifyGraph tick(bottom)=2

ModifyGraph noLabel(left)=1

ModifyGraph mirror(left)=2

ModifyGraph mirror=2

ModifyGraph tick(left)=3

ModifyGraph margin(left)=57,margin(top)=14,margin(right)=14,width=226.772;DelayUpdate

ModifyGraph height=283.465

ModifyGraph gfSize=14

SetAxis/A/R bottom

ModifyGraph margin(bottom)=57

Label bottom "Binding Energy [eV]"

Label left "Intensity [arb. units]"


(3) Creating 1D waves from two 2D waves by pairing the columns at the same index in the 2D waves, and plot them in a graph

#pragma TextEncoding = "UTF-8"

#pragma rtGlobals=3 // Use modern global access method and strict wave access.

Function XYplotsfrom2_2Dwaves(wave1rho,wave2z)  

   wave wave1rho,wave2z

   Variable zmin, zmax, i

   string flagName, DFolder, DestDF, ist, Wave1D

   string w1rho

   //

  w1rho = nameOfWave(wave1rho)

if( WaveDims(wave1rho) != 2)

Abort "rho file is not a two-dimensional wave."

  endif

if( WaveDims(wave2z) != 2)

Abort "z file is not a two-dimensional wave."

  endif

  //

Variable destwvp=DimSize(wave1rho,0)

  Variable destwvq=DimSize(wave1rho,1)

  Variable destscp=DimSize(wave2z,0)

  Variable destscq=DimSize(wave2z,1)

  String   savDF = GetDataFolder(1)

  //

print savDF

DFolder = "XY" + w1rho

NewDataFolder /O $DFolder

DestDF = savDF + DFolder +":"

  print DestDF

  Display

  //

  i = 0

Do

     ist = num2str(i)

     //

Wave1D = w1rho + "_" + ist

Make /O/N=(destwvp) $wave1D

    Wave xy1D = $wave1D

    //

zmin=wave2z[0][i]

zmax=wave2z[destscp-1][i]

SetScale /I  x, zmin, zmax, $wave1D

//

     xy1D[] = wave1rho[p][i]             //extract Column i of the matrix into 1D wave

     appendToGraph xy1D

     MoveWave xy1D, $DestDF

     i += 1

While (i <destwvq)

//

End


6. Making 3D figures using Igor

To make a 3D plot, you need to do following two steps.

a.    Menu "Windows" ->New-  >3D plot

b.    Menu "Gizmo"-> Append surface (or something else such as Scatter,)

(1) Data format 

There are various data formats to be plotted as the "surface" in the 3D plot.  In my case, I mostly use the "matrix" format in which z values sit in a xy 2D matrix.

(2) Colorizing the surface

You can colorize the surface using a fixed color or built-in color tables. To give a special color to the 3D surface other than the fixed colors or the built-in color tables, you need to make your own color wave against the data. How to do that is described in the previous section.

(3) To make a line in 3D plot.

You need to call xyz data as a path through "Append path".  XYZ data is a "n x 3" 2D matrix. Each row composed of 3 columns represents a (x, y, z) address of a data point.

(4) Making a 3D surface from a 1D curve by an operation similar to "extrude" in the adobe illustrator.

You need to make a 2D matrix with the size of n x 2, where n is a length of the 1D data wave.  If the x values are separated by a constant value, you only need to make a  n x 2 matrix and paste the data value to the first and second columns, and scale the x and y indices. 

 If the x values are not regularly separated and stored in a 1D wave, you need to make new x, y, and z 1D waves at first and convert them to a 2D matrix using "XYZ wave to matrix" macro provided by Wavemetrics . The procedure is as follows. 

     Suppose you have x wave and z (data value) wave of n points at the beginning. Make  x1, y1, and z1 1D waves having 2n points. Paste x and z(data) values to 0th to (n-1)th rows of the x1 and z1 waves and again nth to (2n-1)th rows  of the x1 and z1 waves.  Input  a single value such as "0" in the 0th to (n-1)th rows of the y1 wave and input a different value  such as "1" in the nth to (2n-1)th rows of the y1 wave. Click Data->package->XYZ to matrics, and select Macro->XYZ wave to matrix. Specify X1, Y1, and Z1 waves and convert them to matrix. 

In the example below, you are supposed to have a "original_x_wave" of 100 points as the x wave and "original_data_wave" of 100 points as the data wave. 

make/N=(200)/D x1, y1, z1

x1[0,99] = original_x_wave

x1[100,199] = original_x_wave[p-100]

z1[0,99] = original_data_wave

z1[100,199] = original_data_wave[p-100]

y1[0,99]= 0

y1[100, 199] =1

XYZtoMatrixEx("x1",100,"y1",2,"z1","xyzsurface",NaN,1e-05,2,2)

(5) Duplicate a 3D gizmo plot using the window recreation macro

If you want to duplicate a graph window, you can do it by clicking "Duplicate Graph" at Edit menu or just press cntl + D after activating the target graph. However, In the case of GIZMO plot, this method doesn't work. In that case, you can duplicate the gizmo window using a tricky way.

First, close the target window by clicking the x mark at the top right corner. When you press the mark, Igor will ask you "Save window recreation macro as "Gizomo0 (the window name comes here by default)' ?". Click the save button on the window. Though the target window disappears, you can recreate it through Window menu =>Other macros=>Gizmo0. You can make the same window as much as you want using the macro. The name of the windows will be Gizmo0, Gizmo0_1, Gizmo0_2 etc. The macro is "window recreation macro", and you can use this method not only for Gizmo windows, but for graphs, tables, etc.

(6) Find the Gizmo Info window

In some cases, Gizmo info window of a Gizmo plot  does not appear even though you click Gizmo->Show Info or Cntl+I. In such a case, make the gizmo plot window active, click Gizmo->Show Info or Cntl+I, and then select Windows menu->Control->Move to full size position. Your Gizmo info window appears in the maximum size. You can change the size by dragging the sides of the window.

(7) Rotate Gizmo1 to match Gizmo0

https://www.wavemetrics.com/code-snippet/matching-different-gizmos-viewing-angles

In the above forum page, Dr. Chinn gave us a useful function.

 "I often want to look at different 3-D surfaces displayed in separate Gizmos, and view them from the same angle. Here is a tiny, quick-and-dirty aid to doing that."  

function GizMatch(sGizmo0, sGizmo1) // match Gizmo Euler viewing angles,

    string sGizmo0, sGizmo1     // Gizmo window names (strings)


    GetGizmo/N=$sGizmo0 curRotation

    ModifyGizmo/N=$sGizmo1 euler={gizmoEulerA, gizmoEulerB, gizmoEulerC}

end

Though the wavemetrics commented 

"you can right click on a Gizmo window and select from the "Rotate to Match" or "Sync to Gizmo" submenus to accomplish the above.  "

I could not find the  "Rotate to Match" menu, so that the above function helps me a lot

7. Making Movies

(1) Making a movie with higher image resolution

According to a discussion in the Igor forum, the best way to make movies from igor graph is to use igor to creat graphs and use ffmpg to convert them into ffmpg. The discussions and sample code by KZarzana is shown here. https://www.wavemetrics.com/node/21069

A simpler step is to save all the figures into the sub-folder (graph) using the function below (open the Func_allsavegraphs.ipf file in Igor and type SaveAllGraphs() 

at the command window.

Then, drag and drop the necessary figures into imageJ. In ImageJ, make a stack image ( image->stacks->images to stack) and save it as gif (files->save as->gif).

Func_allsavegraphs.ipf

#pragma TextEncoding = "UTF-8"

#pragma rtGlobals=3 // Use modern global access method and strict wave access.


// https://www.wavemetrics.com/forum/general/how-can-i-batch-export-graphs-using-graph-title

// wrote by tony

// adopted here by SNT@NAIST 20221123

function SaveAllGraphs()

   int NGraphs, i

   string graphList, currWindow

 

   GraphList = WinList("*", ";", "WIN:1")    //searching all the graph windows

   NGraphs = ItemsInList(GraphList)

   PathInfo home    //stores information about the named symbolic path in the following variables

   //                 V_flag: 0 if the symbolic path does not exist, 1 if it does exist.

   //                 S_path: The full path (e.g., "hd:This:That:").

   //                 home refers to the home folder for the current experiment.

   NewPath/C/O/Q graphs, S_path + "graphs:"

 

   for (i = 0; i < NGraphs; i += 1)

       currWindow = StringFromList(i, graphList)

       GetWindow $currWindow, wtitle

       SavePICT/Z/O/E=-6/P=graphs/WIN=$currWindow as CleanUpName(s_value, 1) + ".jpg"

   endfor

end