add colors to Make Traces Different?

hello,

Make Traces Different is very close to doing what I need, but with two problems. Perhaps there are other solutions in IGOR but I haven't found them yet.

1) I would like to apply MTD to only a subset of the traces on a graph. For instance with a plot having 24 traces, I want the first 12 traces to be colored uniquely, and the second set of 12 to have the same colors as the first (eg trace 1 and 13 are both red, 2 and 14 are slightly lighter, &c.)

2) I would like to add new color indexes/tables, such as Moreland's SmoothCoolWarm. But it's not obvious how to do this.

 

Thank you for any assistance.

 

My approach would be to code up a solution to this problem. I'm not so familiar with MTD to comment on whether it is possible to do what you want with that package.

Here are two procedures, one to load Moreland's SmoothCoolWarm and one to do something similar to MakeTracesDifferent (I got this a few years ago from IgorExchange - it's edited slightly). Hopefully this is useful to you. It needs to be edited so that: 1. you use SmoothCoolWarm256 rather than M_colors; 2. the loop goes in cycles that you describe and takes the increments of the colorwave you want.

Function LoadNiceCTableW()
	NewDataFolder/O root:Packages
	NewDataFolder/O root:Packages:ColorTables
	String/G root:Packages:ColorTables:oldDF = GetDataFolder(1)
	NewDataFolder/O/S root:Packages:ColorTables:Moreland
	LoadWave/H/O/P=Igor ":Color Tables:Moreland:SmoothCoolWarm256.ibw"
	KillStrings/Z/A
	SetDataFolder root:
	KillStrings/Z root:Packages:ColorTables:oldDF
	KillVariables/Z root:Packages:ColorTables:Moreland:V_flag
End

// This function is from enlacequimico, edit by chozo and me
// It will set the traces to be different colours from a Colour Table
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
	for( index = 0; index < numItems; index += 1 )			
		Variable row = ( index/numItems )*DimSize( M_Colors, 0 )
		traceindex = ( rev == 0 ? index : numItems-1 - 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

 

sjr51, thank you, that was very helpful. I took it, ran, and eventually figured out how to do what I needed. The following allows you to color a selection of traces in a plot, using all or only a portion of a given Color Table. "SmoothCoolWarm256" can of course be replaced by any desired table.

 

 

// numi, numf are the numbers of the first and last traces in the selection of traces to be colored. 
// CTri, CTrf are both between 0 and 1 (CTrf > CTri) and give the range of the color table to use, 
// e.g. CTri = 0 and CTri = 0.4 means the first 40% of the color range of the table is used to color
// the desired traces.

Function ColorTraces(numi,numf,CTri,CTrf,revers)
    Variable numi
    Variable numf
    Variable CTri
    Variable CTrf
    Variable revers
 
    String list = TraceNameList( "", ";", 1 )

    Wave SmoothCoolWarm256 
 
    Variable index, traceindex
    Variable CTdim = round( DimSize(SmoothCoolWarm256,0) * ( Ctrf - Ctri ) )
    for( index = numi; index < numf+1; index += 1 )         
        Variable row = round( (index-numi)/(numf-numi) * (CTrf-CTri) * DimSize(SmoothCoolWarm256, 0) + CTri * DimSize(SmoothCoolWarm256, 0) )
        traceindex = ( revers == 0 ? index : (numf)-1 - index ) 
        Variable red = SmoothCoolWarm256[ row ][ 0 ], green = SmoothCoolWarm256[ row ][ 1 ], blue = SmoothCoolWarm256[ row ][ 2 ]
        ModifyGraph/Z rgb[ traceindex ] = ( red, green, blue )
    endfor
 
End