This article contains a sample script that shows how to create a line/scatter plot in Grapher via automation.
To run this script:
- Copy the script below, or click here to download the BAS file: create line plot example.BAS.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- 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.
- Click Script | Run to run the script.
Sub Main 'Declares GrapherApp as an object Dim GrapherApp As Object 'Creates an instance of the Grapher Application object and assigns it 'to the variable named "GrapherApp" Set GrapherApp = CreateObject("Grapher.Application") 'Makes Grapher visible GrapherApp.Visible = True 'Declares Plot as an object Dim Plot As Object 'Creates a plot document in Grapher and assigns it to the variable 'named "Plot" Set Plot = GrapherApp.Documents.Add(grfPlotDoc) 'Declares Shapes as an object Dim Shapes As Object 'Assigns the AutoShapes collection to the variable named "Shapes" Set Shapes = Plot.Shapes 'Declares LineGraph as an object Dim LineGraph As Object 'Creates a graph and assigns it to the variable named "LineGraph" Set LineGraph = Shapes.AddLinePlotGraph(GrapherApp.Path+"\samples\tutorial.dat") 'Declare LinePlot as an object Dim LinePlot As Object 'Set LinePlot to the first line plot on the LineGraph graph Set LinePlot = LineGraph.Plots.Item(1) End Sub
Updated September 22, 2016