Specify date/time axes limits using Grapher automation

This article contains a sample script for using the DateValue BASIC automation command to specify date/time axes limits.

To run this script:

  1. Click here to download the BAS file: DateTimeAxesLimits.BAS
  2. Click Automation | Scripts | Run, select the BAS file from your downloads directory, and click Open.


  1. Copy the script below.
  2. Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
  3. Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
  4. Press Ctrl+V to paste it into the Script Manager.
  5. Click the Start/Resume icon () in the Script Manager. 

Sub Main

'Initialize Grapher
Dim Grapher As Object
Set Grapher = CreateObject("Grapher.Application")
Grapher.Visible = True
Set Plot1 = Grapher.Documents.Add(grfPlotDoc)

'Create line plot graph
Plot1.Shapes.AddLinePlotGraph("C:\Program Files\Golden Software\Grapher 15 Preview\Samples\3D bar chart.dat",1,2)

'Define object pointers
Set Graph1 = Plot1.Shapes.Item(1)
Set YAxis1 = Graph1.Axes.Item(2)
Set XAxis1 = Graph1.Axes.Item(1)
Set LineScatterPlot1 = Graph1.Plots.Item(1)

'Set TickLabels.UseDateTimeFormat
XAxis1.TickLabels.UseDateTimeFormat = True

'Set Min
XAxis1.AutoMin = False
XAxis1.Min = DateValue("7/2/1905")

'Set Clipping.XMinMode
LineScatterPlot1.Clipping.XMinMode = grfClipAxis

End Sub

Updated August 13, 2019

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



Please sign in to leave a comment.