How to Interactively Create Reusable Graphics Profiles

Introduction

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.

Our Project

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.

Video Tutorial

This video tutorial will show you how to:

  1. Clone an Existing Graph Profile.
  2. Modify Title and Axis Font Settings.
  3. Modify Line Style and Legend Descriptions.
  4. Set the Legend Properties.
  5. Set the Y-axis Label.

or read the text instructions below.

Step 1: Clone an Existing Graph Profile

Create GAUSS graphics profile.

  1. Select Tools > Preferences from the main GAUSS menu.
  2. Select Graphics on the left side of the Preferences window.
  3. Select the Profiles button at the top of the Graphics Preferences.
  4. Select the profile you would like to clone from the dropdown list.
  5. Select the Clone button.
  6. Enter the name for your new profile and click OK.

Step 2: Modify Font Settings

Set the Title Font

Modify graphics profile title font.

Using the graphics profile created in the previous step:

  1. Select Title from the list of graph settings on the left.
  2. 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

Set axes fonts for GAUSS graphics profile.

  1. Select Axes Style from the list of graph settings on the left.
  2. From the Caption section, select the Change button to modify the axes label font.
  3. Click the Numbers Change button and select your preferred font settings for the tick labels.

Step 3: Modify Line Style and Legend Descriptions

Modify line style, legend entry and color for GAUSS graphics preference.

We'll start by modifying the third line which marks the date of the first U.S. location transmission.

  1. Select Series 3.
  2. Enter the legend text for this line in the Legend Title text input box.
  3. Double-click the color box next to Line Color and select a gray color.
  4. 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

Modify legend location, font and border color for GAUSS graphic profile.

  1. Select Legend.
  2. Click the font Change button and set the desired font and font size.
  3. Select the legend location, using the Vertical Position, Horizontal Position, Inside/Outside and Orientation options.
  4. 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

Set axes labels in GAUSS graph profile.

  1. Select Axes Text.
  2. 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:

XY graph using custom graphics profile.

Further Customize

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.

Conclusion

Great job! You've learned how to interactively create custom graphics profiles that can be easily reused and further modified.

Next Steps

Was this post helpful?

Leave a Reply

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy