To create a line/scatter plot:
- 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 Start/Resume icon () in the Script Manager.
Sub Main 'Declares Objects Dim GrapherApp, Plot, Graph, LinePlot As Object 'Create an instance of Grapher named "GrapherApp" Set GrapherApp = CreateObject("Grapher.Application") 'Make Grapher visible GrapherApp.Visible = True 'Create a new plot document named "Plot" Set Plot = GrapherApp.Documents.Add(grfPlotDoc) 'Create a new graph with a single line plot Set Graph = Plot.Shapes.AddLinePlotGraph(GrapherApp.Path + "\Samples\bar chart orientations.dat") 'Set the line plot to the variable named "LinePlot" Set LinePlot = Graph.Plots.Item(1) 'Set the X and Y columns LinePlot.xCol = 1 LinePlot.yCol = 2 'Adjust properties of the X axis Set XAxis1 = Graph.Axes.Item(1) XAxis1.title.text = "" XAxis1.AutoMin = False XAxis1.Min = 1 XAxis1.Tickmarks.MajorSpacingAuto = False XAxis1.Tickmarks.MajorSpacing = 5 XAxis1.Tickmarks.MinorSide = grfTicksBottomLeft XAxis1.Tickmarks.MinorDivision = 5 'Adjust properties of the Y axis Set YAxis1 = Graph.Axes.Item(2) YAxis1.title.text = "" YAxis1.Tickmarks.MinorDivision = 4 YAxis1.Grid.AtMinorTicks = True YAxis1.Grid.MinorLine.style = "Dots" YAxis1.Grid.MinorLine.foreColor = grfColorBlack30 'Changes the line color LinePlot.line.foreColor = grfColorNavyBlue 'Display a symbol at every data point on the plot LinePlot.symbolFreq = 1 'Set the Fill pattern and color LinePlot.Fill.SetPattern("Solid") LinePlot.Fill.foreColor = grfColorNavyBlue LinePlot.Fill.ForeOpacity = 10 End Sub
Updated August 2019