By Leslie McWhirter on Tuesday, 16 May 2017
Category: Grapher

How to automate graph creation in Grapher without having to learn Scripter

Our Grapher, Surfer, Voxler, and MapViewer applications all come with powerful automation functionality to speed up repetitive processes, but many users don't have experience with scripting so they miss out on this functionality. Luckily for those users, Grapher comes with a script recorder that records a script for the process that's being performed in the user interface. This blog article will walk through a simple example of how to use this script recorder, so you can begin automating your work without having to learn how to script.

Let's say you want to a line plot like this for multiple data files.

  1. Click Developer | Scripts | Record to start recording the script.
  2. Click Graphs | Create | Basic | Line Plot.
  3. In the Open Worksheet dialog select the 3D bar chart.dat sample file. Click Open.
  4. With Line/Scatter Plot 1 selected in the Object Manager, click on the Line tab in the Property Manager
    1. Change the Color to Desert Blue.
    2. Type 0.030 into the Width field and press ENTER on your keyboard.
  5. Select Y Axis 1 in the Object Manager.
  6. On the Tick Marks page in the Property Manager
    1. In the Major Ticks section, change the Spacing to 1000 and press ENTER on your keyboard.
    2. Uncheck the box next to Show ticks on left.
    3. In the Minor Ticks section, uncheck the box next to Show ticks on left.
  7. On the Grid Lines page, 
    1. In the Major Lines section check the box next to At major ticks
    2. Expand the Major line properties subsection and set the Color to 30% Black.
  8. On the Line page, set the Color to 30% Black
  9. Select X Axis 1 in the Object Manager
  10. On the Line page in the Property Manager, set the Color to 30% Black
  11. Select Graph 1 in the Object Manager
  12. On the Title page in the Property Manager, click the Editor button in the Title field. 
  13. Type U.S. Income over Time (2000-2015) into the Text Editor
  14. Highlight the text and change the size to 18 pts
  15. Click OK
  16. On the Title page in the Property Manager, expand the Box Line Properties section and change the Style to Invisible
  17. Click File | Save As.
  18. In the Save As dialog, give your file a name and click Save
  19. Click Developer | Scripts | Stop Recording
  20. In the Save As dialog, give your script a name and a location and click Save. This saved script is attached for comparison with your own. 

If you have a whole bunch of data files, you may be interested in adding a loop to do this for all data files in a specific directory, but for only a few data files, it's easier for novice scripters to just run the script for each data file. To do this: 

  1. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12\Scripter
  2. Double click on Scripter.exe to open Scripter. 
  3. Click File | Open
  4. In the Open dialog, select the script file you saved in step 20 above and click Open
    • Change line 17, to reflect the file name and path of your new data file (red box below). The numbers after the name/path are the x column and y column that are being plotted (blue box below). 

  1. Click Script | Run. Your plot is created with the same settings as the first plot was, and is saved to the specified name.

You don't have to be an expert scripter to automate your workflow in Grapher. If you want to become an expert, see these resources:

Also be on the lookout for the upcoming knowledge base article: What is the easiest way to learn Grapher's Scripter?

Leave Comments