Change the axis settings via Surfer automation

All of the available axis properties can be reviewed in the Axis Object Help topic.  A full sample script for this process is provided below.
Before you can change the settings of any individual axis, it must first be accessed through the Axes collection as shown below.
Dim Axes, XAxis As Object
Set Axes = MapFrame.Axes

'Assigns the bottom X axis to the variable named "XAxis", instead of 1 you could use "bottom axis"
Set XAxis = Axes(1)
XAxis.Title = "X Axis Title"


To run this script:

  1. Copy the script below.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer\Scripter.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. Press Ctrl+V to paste the script into Scripter.
  6. Click Script | Run to run the script.
     

*********

Sub Main
    Dim SurferApp As Object
Set SurferApp = CreateObject("Surfer.Application") SurferApp.Documents.Add(srfDocPlot) SurferApp.Visible = True Infile = SurferApp.Path + "\samples\demogrid.grd" Dim Plot, MapFrame, Axes, Axis As Object Set Plot = SurferApp.Documents.Add Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=Infile) Set Axes = MapFrame.Axes For Each Axis In Axes Axis.ShowLabels = False Axis.MajorTickType = srfTickNone Axis.MinorTickType = srfTickNone Next Axis End

See also the attached script, Axes.bas, which can also be found in the \Samples\Scripts\ folder in the Surfer installation directory.

 

Updated November 2021

Was this article helpful?
0 out of 2 found this helpful

Comments

2 comments
Date Votes
  • I am looking for definition of the Axes object. If 1 is the bottom axis, how are the rest of the axes defined? Is left axis 2? Feel free to point me to a Help section where the object is defined. 

    0
  • Hi Kien,

    Thank you for your post! We spoke earlier over LiveChat, but I wanted to reply as this is a good question and I am sure others will benefit from the answer. 

    The axes objects do not need to be defined. They are predefined in Surfer already as the following in a 2D map:

    BottomAxis

    TopAxis

    LeftAxis

    RightAxis

    In a 3D map, they are defined as the following:

    XAxis

    YAxis

    ZAxis

    Another great example of how to use these objects (including creating variables for them) can be found in the sample script Axes.bas found by default in C:\Program Files\Golden Software\Surfer 16\Samples\Scripts.

    More information can be found in Surfer's Help on the Axis object page that is linked above. 

    Thank you,

    Brittany

    Golden Software Support

    0

Please sign in to leave a comment.