There are numerous methods available for applying a colormap to contour maps in Surfer, from loading a CLR file or preset colormap to defining individual colors. Five of the most common methods for applying colors to contour maps via automation are described below.
Method 1: Select a Preset colormap
You can select one of the existing presets to set the contour color to.
Set MapFrame = Plot.Shapes.AddContourMap(SurferApp.Path+"\samples\demogrid.grd") Dim ContourLayer As Object Set ContourLayer = MapFrame.Overlays(1) ContourLayer.FillContours = True ContourLayer.FillForegroundColorMap.LoadPreset("Rainbow5") ContourLayer.ApplyFillToLevels(FirstIndex:=1, NumberToSet:=1, NumberToSkip:=0)
See also the attached script ContourMap.bas, which can also be found in the \Samples\Scripts\ folder in the Surfer installation directory.
Method 2: Load a CLR file
You can create and load a color CLR file:
Set MapFrame = Plot.Shapes.AddContourMap(SurferApp.Path+"\samples\demogrid.grd") Dim ContourLayer As Object Set ContourLayer = MapFrame.Overlays(1) ContourLayer.FillContours = True ContourLayer.FillForegroundColorMap.LoadFile(SurferApp.Path+"\Samples\Rainbow.clr") ContourLayer.FillPattern = "Periglacial-1" ContourLayer.FillTransparent = False ContourLayer.FillBackgroundColorMap.LoadFile(SurferApp.Path+"\Samples\Taffy.clr") ContourLayer.ApplyFillToLevels(1, 1, 0)
*Note* in line 5, Surfer 15 and previous would look as follows:
ContourLayer.FillForegroundColorMap.LoadFile(SurferApp.Path+"Rainbow.clr")
See also the attached script ContourMap.bas, which can also be found in the \Samples\Scripts\ folder in the Surfer installation directory.
Method 3: Set Min and Max Color
You can specify a color gradient by choosing a minimum and maximum color.
Set MapFrame = Plot.Shapes.AddContourMap(SurferApp.Path+"\samples\demogrid.grd") Dim ContourLayer As Object Set ContourLayer = MapFrame.Overlays(1) ContourLayer.FillContours = True Set Levels = ContourLayer.Levels 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(0,255-ColorInc,ColorInc) Next i
Method 4: Set Individual Level Colors
You can specify the colors for each individual color level. This example changes the colors for levels 2, 5, 8, and 10:
Set MapFrame = Plot.Shapes.AddContourMap(SurferApp.Path+"\samples\demogrid.grd") Dim ContourLayer, Levels As Object Set ContourLayer = MapFrame.Overlays(1) ContourLayer.FillContours = True Set Levels = ContourLayer.Levels Levels(8).Line.ForeColor = srfColorYellow Levels(8).Line.Width = 0.05 Levels(8).Fill.ForeColor = srfColorBlue Levels(2).Line.ForeColor = srfColorBlue Levels(2).Line.Width = 0.03 Levels(5).Line.ForeColor = srfColorRed Levels(5).Line.Width = 0.02 Levels(10).Line.ForeColor = srfColorGreen Levels(10).Line.Width = 0.04
Method 5: Load an LVL File
You can create and load a level LVL file (attached):
Set MapFrame = Plot.Shapes.AddContourMap(SurferApp.Path+"\samples\demogrid.grd") Dim ContourLayer As Object Set ContourLayer = MapFrame.Overlays(1) ContourLayer.FillContours = True Set Levels = ContourLayer.Levels Levels.LoadFile(SurferApp.Path+"\samples\demogrid.lvl") ContourLayer.FillContours = True
Additional information about creating a LVL file can be found in the articles below:
For more contour map and colormap scripting examples, see the sample scripts
- ColorMap CLR files.bas
- ColorMap_LoadPreset.bas
- ContourMap.bas
- ContourMap_Advanced.bas
- ContourMap_Logarithmic.bas
- ContourMap_Simple.bas
located in the \Samples\Scripts\ folder in the Surfer installation directory.
Note: Only methods 3 and 4 are available in Surfer 9 and earlier versions
Updated October 2021
Comments
Please sign in to leave a comment.