Follow

How can I change the contour map fill color via Surfer automation?

This article describes five different methods for changing the fill color of a contour map via Surfer automation.
 

Method 1: Selecting a Preset

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: Loading 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+"\ColorScales\Rainbow.clr")
ContourLayer.FillPattern = "Periglacial-1"
ContourLayer.FillTransparent = False
ContourLayer.FillBackgroundColorMap.LoadFile(SurferApp.Path+"\ColorScales\Taffy.clr")
ContourLayer.ApplyFillToLevels(1, 1, 0)

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 could 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 could 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:

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

 

Updated October 9, 2017

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.