Make graph with WaveName
Narno
I've a lot of data to import in a graph (~300 waves) and I don't know how to make a macro able to plot a wave vs an other just using their name.
I have a folder with X vawes : 'E_1_xxx' 'E_2_yyy' 'E_3_zzz' and an other for Y waves 'S_1_xxx' 'S_2_yyy' 'S_3_zzz' (I can merge both if necessary of course) , where xxx yyy zzz are strings containing wave's informations (same strings for same 'E' and 'S' waves number).
Is that possible to make a macro to plot 'S_1_xxx' vs 'E_1_xxx' until the total number of wave?
I am not asking for a complete code (unless you have it :) ) but just for advises and ideas !
Thanks !
1. set datafolder to the x folder. Use WaveList to get a string list of all the waves in the X folder
2. repeat step 1 for the y folder. You now have 2 strings which contain all the wave names you need.
string ynames
variable i
for (i=0; i<itemsinlist(xnames); i+=1)
display $(stringfromlist(i; ynames; ";")) vs $(stringfromlist(i; xnames; ";"))
endfor
this will make 1 graph for each xy pair. Since the two lists will be sorted in the same manner, the X and Y names should be in the correct order.
March 28, 2013 at 11:52 am - Permalink
I'll try it and keep you posted !
March 29, 2013 at 03:13 am - Permalink
March 29, 2013 at 06:07 am - Permalink
Here is the final code :
"FEES.../1", GraphE_S() //Ctrl+1
End
Macro GraphE_S()
GraphES()
End
Function GraphES()
string xnames = WaveList("E*",";","")
string ynames = WaveList("S*",";","")
variable i
display $(stringfromlist(0, ynames, ";")) vs $(stringfromlist(0, xnames, ";"))
for (i=1; i<itemsinlist(xnames); i+=1)
AppendToGraph $(stringfromlist(i, ynames, ";")) vs $(stringfromlist(i, xnames, ";"))
endfor
end
I've finally merged my two data folders, it's easier to call xnames and ynames and I display all the waves on the same graph.
In this case, all waves have the same color, so I use this code (which can be useful for someone else !) :
"Color waves.../2", ColorWaves() //Ctrl+2
End
Macro ColorWaves()
Variable rev = 1
String colorTable = "dbZ14" // Choose the colorTable you prefer in Igor !
ColorTraces(rev, colorTable)
End
Function ColorTraces(rev, colorTable)
Variable rev
String colorTable
String list = TraceNameList( "", ";", 1 )
Variable numItems = ItemsInList( list )
if ( numItems == 0 )
return 0
endif
ColorTab2Wave $colorTable
Wave M_colors
Variable index, traceindex, step
step =0;
for( index = 0; index < numItems; index += 1 )
if (step/DimSize( M_Colors, 0 ) == 1)
step=0;
endif
Variable row = step //( index/numItems )*DimSize( M_Colors, 0) if you prefer a gradient
traceindex = ( rev == 0 ? index : numItems - index )
Variable red = M_Colors[ row ][ 0 ], green = M_Colors[ row ][ 1 ], blue = M_Colors[ row ][ 2 ]
ModifyGraph/Z rgb[ traceindex ] = ( red, green, blue )
step+=1
endfor
KillWaves/Z M_colors
End
March 29, 2013 at 07:31 am - Permalink
March 29, 2013 at 08:36 am - Permalink