Follow

How can I hide the axes on my map via Surfer automation?

This article contains a sample script for hiding axes (including removing tick marks and labels) for selected maps in an open SRF file.

To run this script:

  1. Copy the script below, or download the attached BAS file: HideAxes.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 14\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. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.
     

*********

'HideAxes.bas eliminates ticks, labels, and axis titles, and hides the axes
'for selected maps in an open SRF file. It ignores selected objects that are not maps.
'Does not work for maps grouped into composite objects.

'1. Open SRF file.
'2. Select the maps to eliminate the axes.
'3. Run script.

'=======================================

Sub Main
	Debug.Clear
	'Use existing Surfer instance.
	On Error GoTo Error1:
  	Set surf = GetObject(, "Surfer.Application")
	On Error GoTo 0

	Set document = surf.ActiveDocument
	If  document.Type <> srfDocPlot Then GoTo Error2:

	Debug.Print "Surfer Version:     " & surf.Version
	Debug.Print "Document:           " & surf.ActiveDocument

	Set selection = document.Selection
	i = 0
	For Each obj In selection
		If obj.Type = srfShapeMapFrame Then
			i = i + 1
			Debug.Print "Modified Map" & i & ":      " & obj.Name
			shrinkAxes(obj)
		End If
	Next obj
	If i = 0 Then GoTo Error3:

GoTo Xit:

Error1:
Debug.Clear
Debug.Print "Surfer is not running.  Start Surfer, open a document, and select maps to modify."
GoTo Xit:

Error2:
Debug.Clear
Debug.Print "Active document is not a plot. Open or activate a plot document and select a maps to modify."
GoTo Xit:

Error3:
Debug.Clear
Debug.Print "No maps selected.  Select some maps to modify."
Debug.Print "Make sure your maps are Not inside a composite Object."
GoTo Xit:

Xit:
End Sub

Public Function shrinkAxes(frame As Object)
	For Each axis In frame.Axes
		axis.ShowLabels = False
		axis.MajorTickType = srfTickNone
		axis.MinorTickType = srfTickNone
		axis.Visible = False
		axis.Title = ""
	Next axis
End Function

 

Updated February 13, 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.