Color traces on graph
enlacequimico
Menu "Macros"
"Color waves.../1", ColorWaves() //Ctrl+1
End
Macro ColorWaves()
Variable rev = 1
String colorTable = "RainbowCycle"
ColorTraces(rev, colorTable)
End
Function ColorTraces( rev, colorTable )
//% V1.5
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
for( index = 0; index < numItems; index += 1 )
Variable row = ( index/numItems )*DimSize( M_Colors, 0 )
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 )
endfor
KillWaves/Z M_colors
End
"Color waves.../1", ColorWaves() //Ctrl+1
End
Macro ColorWaves()
Variable rev = 1
String colorTable = "RainbowCycle"
ColorTraces(rev, colorTable)
End
Function ColorTraces( rev, colorTable )
//% V1.5
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
for( index = 0; index < numItems; index += 1 )
Variable row = ( index/numItems )*DimSize( M_Colors, 0 )
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 )
endfor
KillWaves/Z M_colors
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
Variable rev = 1
Prompt rev, "1 for Reverse, else 0"
String colorTable = "RainbowCycle"
Prompt colorTable, "Color Table", popup, CTabList()
ColorTraces(rev, colorTable)
End
I didn't propose a popup for the rev, because it'd change the values from 0 and 1 to 1 and 2.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
May 7, 2012 at 05:25 pm - Permalink
January 30, 2016 at 07:34 am - Permalink
I may be mistaken but I think the row variable also has an off-by-one index error - not a big deal on a large colortable and many traces, but I think the line below would allow you to have traces filling out the full spectrum of the color table:
May 17, 2016 at 06:51 am - Permalink