Yes, you can load a CLR file for a contour map in Surfer via automation. In Surfer 16, the only preset saved as a CLR file is the rainbow preset and it is located in the \Samples\ folder in the Surfer installation directory. The below example can be used where the (SurferApp.Path+"\Samples\Rainbow.clr") portion can be changed to your directory containing the desired CLR file.
'Load a CLR file for the contour layer ContourLayer.FillForegroundColorMap.LoadFile(SurferApp.Path+"\Samples\Rainbow.clr") 'Applies the above fill settings to the layer ContourLayer.ApplyFillToLevels(1, 1, 0)
In Surfer 15 and previous, all the CLR files for all the presets are saved to the installation file under the ColorScales folder. The following example can be used:
'Load a CLR file for the contour layer ContourLayer.FillForegroundColorMap.LoadFile(SurferApp.Path+"Rainbow.clr") 'Applies the above fill settings to the layer ContourLayer.ApplyFillToLevels(1, 1, 0)
For more examples on scripting with contour maps, see the sample script ContourMap.bas in the \Samples\Scripts\ folder in the Surfer installation directory.
Surfer 9 and previous versions do not have the ability to load a CLR file or specify a preset colormap to a contour map in a script. Instead, you can specify the minimum and maximum colors and create a color gradation between them. For example:
'Set the colors to go from blue to red n = Levels.Count ColorInc = 255.0 / (n-1) For i=1 To n ColorInc = 255.0 * (i-1) / (n-1) Levels(i).Fill.foreColor = RGB(ColorInc,0,255-ColorInc) Next i 'Set the colors to go from blue to white m = Levels2.Count ColorInc2 = 255.0 / (m-1) For j=1 To m ColorInc2 = 255.0 * (j-1) / (m-1) Levels2(j).Fill.foreColor = RGB(ColorInc2,ColorInc2,255) Next j
See also the attached contourfill.bas script.
Updated September 27, 2017
Comments
0 comments
Please sign in to leave a comment.