How can I link plot names for all plots in my Grapher graph to worksheet cells?

There is not a direct way from the user-interface to link plot names to worksheet cells, but you can get this result by running the script below. 

To run this script:

  1. Click here to download the BAS file: NamePlots.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. 

'1. Open a Grapher file with one graph containing many plots from a single data file.
'2. Define the datafile that these plots were created from (line 18).
'3. Define a shift such that 1+shift=first variable column number (line 19)
'   (i.e. if first variable col is B [2], shift=1).
'4. Script changes the plot names to the variable name from the header row.
Sub Main

'Initializes Grapher
Dim Grapher As Object
Set Grapher = CreateObject("Grapher.Application")
Grapher.Visible = True

'User-defined variables
datafile="C:\program files\golden software\grapher 12\samples\3D bar chart.dat"
shift = 1 'Number to add to 1 to get to the first variable column

'Defines the active plot window and opens the desired data file in the worksheet
Set Plot1 = Grapher.Documents.Active
Set Data = Grapher.Documents.Open(datafile)

'Defines the Graph object
Set Graph1 = Plot1.Shapes.Item(1)

'Loops through all of the plots, setting the plot names to the header row from the data
For i=1 To Graph1.Plots.Count
    Graph1.Plots.Item(i).Name = Clipboard$()
Next i

End Sub


Updated January 18, 2018

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.