ColorMap Object

The ColorMap object defines a mapping between a range of data and a spectrum of colors. The properties and methods coincide with the Colormap Editor within Surfer.

The following table provides the properties of the ColorMap object.

Property

Description

Application

Returns the application object. It is a read-only property.

ColorNodes

Returns the color nodes collection. Updates the color map from a color nodes collection.

DataMax

Returns the data value corresponding to the maximum color. It is a read-only property.

DataMin

Returns the data value corresponding to the minimum color. It is a read-only property.

Parent

Returns the parent object. It is a read-only property.

ScalingMethod

Returns or sets the scaling method

The following table provides the methods of the ColorMap object:

Method

Description

DatToPos

Converts a data value to a position (0.0 to 1.0).

LoadFile

Loads the specified colormap file.

LoadPreset

Loads a preset colormap

PosToDat

Converts a position (0.0 to 1.0) to a data value.

Reverse

Reverses the order of nodes in the colormap.

SaveFile

Saves the color map to the specified file.

SetDataLimits

Set the data limits for the minimum and maximum color.

Example

The following script demonstrates how the ColorMap object is used in reference to the ImageLayer object.

Sub Main

 

'Declares SurferApp as an object

Dim SurferApp As Object

 

'Creates an instance of the Surfer Application object and assigns it

'to the variable named "SurferApp"

Set SurferApp = CreateObject("Surfer.Application")

 

'Makes Surfer visible

SurferApp.Visible = True

 

'Declares Plot as an object

Dim Plot As Object

 

'Creates a plot document in Surfer and assigns it to the variable

'named "Plot"

Set Plot = SurferApp.Documents.Add(srfDocPlot)

 

'Declares Shapes as an object

Dim Shapes As Object

 

'Assigns the Shapes collection to the variable named "Shapes"

Set Shapes = Plot.Shapes

 

'Declares MapFrame as an object

Dim MapFrame As Object

 

'Creates a color relief map and assigns the map coordinate system to the

'variable named "MapFrame"

Set MapFrame = Shapes.AddColorReliefMap(GridFileName:=SurferApp.Path+"\Samples\demogrid.grd")

 

'Declares ColorReliefLayer as an object

Dim ColorReliefLayer As Object

 

'Assigns the color relief map properties to the variable named "ColorReliefLayer"

Set ColorReliefLayer = MapFrame.Overlays(1)

 

'Declares ColorMap as an object

Dim ColorMap As Object

 

'Assigns the color spectrum properties to the variable named

'"ColorMap"

Set ColorMap = ColorReliefLayer.ColorMap

 

'Sets the color map to use log scaling

ColorMap.ScalingMethod = srfColorScalingLog

 

End Sub

Example 2

The following script demonstrates how the ColorMap object is used in reference to the ContourLayer object.

 

Sub Main

 

'Declares SurferApp as an object

Dim SurferApp As Object

 

'Creates an instance of the Surfer Application object and assigns it

'to the variable named "SurferApp"

Set SurferApp = CreateObject("Surfer.Application")

 

'Makes Surfer visible

SurferApp.Visible = True

 

'Declares Plot as an object

Dim Plot As Object

 

'Creates a plot document in Surfer and assigns it to the variable

'named "Plot"

Set Plot = SurferApp.Documents.Add(srfDocPlot)

 

'Declares Shapes as an object

Dim Shapes As Object

 

'Assigns the Shapes collection to the variable named "Shapes"

Set Shapes = Plot.Shapes

 

'Declares MapFrame as an object

Dim MapFrame As Object

 

'Creates a contour map and assigns the map coordinate system to the

'variable named "MapFrame"

Set MapFrame = Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\Samples\demogrid.grd")

 

'Declares ContourLayer as an object

Dim ContourLayer As Object

 

'Assigns the contour map properties to the variable named "ContourLayer"

Set ContourLayer = MapFrame.Overlays(1)

 

'Fills the contour layer contours

ContourLayer.FillContours = True

 

'Set the contour level method to simple

ContourLayer.LevelMethod = SrfConLevelMethodSimple

 

'Declares ColorMap as an object

Dim ColorMap As Object

 

'Assigns the color spectrum properties to the variable named

'"ColorMap"

Set ColorMap = ContourLayer.FillForegroundColorMap

 

'Loads a preset colormap

ColorMap.LoadPreset ("Rainbow")

 

'Changes the colormap data limits

ColorMap.SetDataLimits(0.1, 100)

 

'Changes the colormap scaling method to Log scaling

ColorMap.ScalingMethod = srfColorScalingLog

 

End Sub