You probably know that you can use GAUSS code to create repeatable styling for your graphs. However, you might not know that GAUSS also allows you to build reusable graphics profiles with a few clicks of your mouse.
We will show you how to clone existing graphics profiles and how to control:
- Font settings for the title, axes labels, and tick labels.
- Line colors and styles.
- Legend location and styling.
While this tutorial will not cover all available options, you should learn enough to be comfortable making most other changes without additional help.
For this tutorial, our goal will be to create a graph profile to replicate the style of the graph below. Data for the graph can be downloaded from here.
This video tutorial will show you how to:
- Clone an Existing Graph Profile.
- Modify Title and Axis Font Settings.
- Modify Line Style and Legend Descriptions.
- Set the Legend Properties.
- Set the Y-axis Label.
or read the text instructions below.
Step 1: Clone an Existing Graph Profile
- Select Tools > Preferences from the main GAUSS menu.
- Select Graphics on the left side of the Preferences window.
- Select the Profiles button at the top of the Graphics Preferences.
- Select the profile you would like to clone from the dropdown list.
- Select the Clone button.
- Enter the name for your new profile and click OK.
Step 2: Modify Font Settings
Set the Title Font
Using the graphics profile created in the previous step:
- Select Title from the list of graph settings on the left.
- Click Change button on the right.
This will open your operating system's font dialog, where you can select your desired font, weight, and size:
Set the Axes Label and Tick Label Fonts
- Select Axes Style from the list of graph settings on the left.
- From the Caption section, select the Change button to modify the axes label font.
- Click the Numbers Change button and select your preferred font settings for the tick labels.
Step 3: Modify Line Style and Legend Descriptions
We'll start by modifying the third line which marks the date of the first U.S. location transmission.
- Select Series 3.
- Enter the legend text for this line in the Legend Title text input box.
- Double-click the color box next to Line Color and select a gray color.
- Select Dash Line from the dropdown box next to Style.
Then repeat step 2 above to add the legend text for Series 1 and Series 2.
Step 4: Set the Legend Properties
- Select Legend.
- Click the font Change button and set the desired font and font size.
- Select the legend location, using the Vertical Position, Horizontal Position, Inside/Outside and Orientation options.
- Double-click the color box next to Line Color and set it to white so the legend outline is unseen.
Step 5: Set Y-axis Label
- Select Axes Text.
- Enter the desired axis label in the appropriate text box.
Use the Custom Graphics Profile
You can access the settings from a graph profile using the
plotGetDefaults function as you would for the default settings. Below is a simple example.
// Load variables Y = loadd("cook-county-covid.csv", "cases + deaths"); x = seqa(1, 1, rows(Y)); // Declare myPlot to be a plotControl structure // and fill with the settings from our covid profile struct plotControl myPlot; myPlot = plotGetDefaults("covid"); // Draw plot using covid profile settings plotXY(myPlot, x, Y);
which will produce the plot below:
While the graphs for a given project may share many features, it is likely that some attributes such as the title or legend text will need to be different. You could clone your custom profile and make these changes. However, it might be simpler to make these changes in your code.
Fortunately, you can use the
plotSet functions to further customize the settings for a particular graph. You can modify any settings that you would like to change.
The code below shows how to change the title, keeping all other settings unchanged.
// Load variables Y = loadd("cook-county-covid.csv", "cases + deaths"); x = seqa(1, 1, rows(Y)); // Declare myPlot to be a plotControl structure // and fill with the settings from our covid profile struct plotControl myPlot; myPlot = plotGetDefaults("covid"); // Set title text plotSetTitle(&myPlot, "COVID-19 Cook County"); // Draw plot using covid profile settings plotXY(myPlot, x, Y);
These settings will not modify the custom graphics profile that you created. Next time you call
myPlot = plotGetDefaults("covid"),
myPlot will be filled with the custom profile settings that you selected in the Preferences dialog window.
Full Code for Time Series Plot
Full code to create the time series plot shown at the top of this post, using the "covid" custom graphics profile we created, can be downloaded here.
Great job! You've learned how to interactively create custom graphics profiles that can be easily reused and further modified.
- How to Mix, Match and Style Different Graph Types.
- Five Hacks For Creating Custom GAUSS Graphics.
- Graph high-frequency Forex data.