This article contains Grapher sample script that shows how to create a graph with line plots and bar charts and export to a JPG file.
To run this script:
- Copy the script below.
- Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
- Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
- Press Ctrl+V to paste it into the Script Manager.
- Click the green arrow Start/Resume icon in the Script Manager.
'Declares GrapherApp as an object Dim GrapherApp, Plot, Graph, LinePlot As Object Set GrapherApp = CreateObject("Grapher.Application") GrapherApp.Visible = True Set Plot = GrapherApp.Documents.Add(grfPlotDoc) 'Creates a line plot Set Graph = Plot.Shapes.AddLinePlotGraph(GrapherApp.Path+"\samples\tutorial.dat") Set LinePlot = Graph.Plots.Item(1) 'Add line plot that uses columns A and C for X and Y Graph.AddLinePlot(GrapherApp.Path+"\samples\tutorial.dat",1,3) 'Export to JPG Plot.Export(GrapherApp.Path+"\samples\tutorial.jpg")
Updated October 8, 2018