3 minutes reading time
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.
- Click Developer | Scripts | Record to start recording the script.
- Click Graphs | Create | Basic | Line Plot.
- In the Open Worksheet dialog select the 3D bar chart.dat sample file. Click Open.
- With Line/Scatter Plot 1 selected in the Object Manager, click on the Line tab in the Property Manager.
- Change the Color to Desert Blue.
- Type 0.030 into the Width field and press ENTER on your keyboard.
- Select Y Axis 1 in the Object Manager.
- On the Tick Marks page in the Property Manager,
- In the Major Ticks section, change the Spacing to 1000 and press ENTER on your keyboard.
- Uncheck the box next to Show ticks on left.
- In the Minor Ticks section, uncheck the box next to Show ticks on left.
- On the Grid Lines page,
- In the Major Lines section check the box next to At major ticks.
- Expand the Major line properties subsection and set the Color to 30% Black.
- On the Line page, set the Color to 30% Black.
- Select X Axis 1 in the Object Manager.
- On the Line page in the Property Manager, set the Color to 30% Black.
- Select Graph 1 in the Object Manager.
- On the Title page in the Property Manager, click the Editor button in the Title field.
- Type U.S. Income over Time (2000-2015) into the Text Editor.
- Highlight the text and change the size to 18 pts.
- Click OK.
- On the Title page in the Property Manager, expand the Box Line Properties section and change the Style to Invisible.
- Click File | Save As.
- In the Save As dialog, give your file a name and click Save.
- Click Developer | Scripts | Stop Recording.
- 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:
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12\Scripter.
- Double click on Scripter.exe to open Scripter.
- Click File | Open.
- 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).
- In line 122, change the file name and path (red box below) to reflect your desired name and location.
- 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?