Plot two plots on a single graph and edit the plot properties via Grapher automation

This article contains a sample script for creating two line/scatter plots on the same graph and altering the properties of one.

To run this script:

 

  1. Copy the script below or download the attached BAS file: Two Line Plot Graph.bas
  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 green arrow Start/Resume icon in the Script Manager. 
     

Sub Main

 'Initialize Grapher
 Dim GrapherApp, Plot, Graph1, ScatterPlot As Object
 Set GrapherApp = CreateObject("Grapher.Application")
 GrapherApp.Visible = True
 Set Plot = GrapherApp.Documents.Add(grfPlotDoc)

 'Create a line plot
 Set Graph1 = Plot.Shapes.AddLinePlotGraph(GrapherApp.Path+"\samples\tutorial.dat")

 'Add a line plot to the graph
 Graph1.AddLinePlot(GrapherApp.Path+"\samples\tutorial.dat", 1, 3)

 'Change the first plot to a scatter plot
 Set ScatterPlot = Graph1.Plots.Item(1)
 ScatterPlot.symbolFreq = 1
 ScatterPlot.line.style("invisible")

 'Set the symbol properties for the scatter plot
 ScatterPlot.symbol.Index = 38
 ScatterPlot.symbol.size = 0.35
 ScatterPlot.symbol.color = RGB(255,0,0)
 ScatterPlot.symbol.lineColor = grfColorBlue

End Sub

 

Updated March 12, 2020

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

Comments

0 comments

Please sign in to leave a comment.