How to Create Tiled Graphs in GAUSS

Introduction

Placing graphs next to each other can be a great way to present information. Today we will learn how to create tiled graphs in GAUSS using plotLayout.

We will work through two simple examples where you will learn:

  • How to created tiled layouts which are uniform and layouts with graphs of different sizes.
  • Which graph types can be used with plotLayout.
  • How to clear your tiled graph layouts.

How to use plotLayout

In GAUSS, plotLayout allows you to arrange multiple graphs in a tiled layout. It takes the following inputs:


g_rows
The number of rows in the graph grid.
g_cols
The number of columns in the graph grid.
idx
The cell in which to place the next graph, walking along the rows.

Therefore, the call:

plotLayout(2, 3, idx);

will:

  1. Split the graph canvas into a 2x3 grid.
  2. Place the next graph in the cell corresponding to the value of idx as shown below.
idx = 1idx = 2idx = 3
idx = 4idx = 5idx = 6

Which Graph Types Can be Used with plotLayout?

Below is a partial list of the GAUSS graph functions which can be used with plotLayout. Each cell is independent and may contain a different graph type.

Function Graph type
plotXY XY line.
plotScatter 2-D Scatter.
plotTS Time series line.
plotTSHF High frequency and irregular time series lines.
plotBar 2-D bars.
plotBox Box plots.
plotHist, plotHistP Standard and percentage histograms.
plotLogX, plotLogY, plotLogLog Line plot where one or more of the axes are in log space.
plotContour Contours.
plotArea Stacked area.
plotXYFill Area between two vectors.

Example 1: Uniform Grid Layout

Now that we have seen the basics of plotLayout, let's put together a simple example placing 4 graphs in a 2x2 grid.

new;

// Create the vector 0.1, 0.2, 0.3...3.0
x = seqa(0.1, 0.1, 30);

/*
** First subplot
*/

// Divide the graph canvas into a 2x2 grid
// and place the next graph in the 1st cell
plotLayout(2, 2, 1);

// Create 'y1' and draw graph
y1 = exp(x);
plotXY(x, y1);

/*
** Second subplot
*/
plotLayout(2, 2, 2);

y2 = sin(x);
plotXY(x, y2);

/*
** Third subplot
*/
plotLayout(2, 2, 3);

y3 = cos(x);
plotXY(x, y3);

/*
** Fourth subplot
*/
plotLayout(2, 2, 4);

y4 = ln(x);
plotXY(x, y4);

After running the above code, you should see a graph that looks like this:

Simple GAUSS tiled graph.

Clearing the Plot Layout

What do you think would happen if we created another plot right after running the code from the previous section? Let's try it with the code below.

// Create new 'y' by adding uniform random
// numbers to the 'x' created above
y = x + rndu(30,1);

// Draw graph
plotScatter(x, y);

This time your graph should look like this:

Subplots in GAUSS.

As we can see, GAUSS remembers the grid we created with our last call to plotLayout as well as the chosen cell index. This state will persist until one of the following statements has been executed:

// Subsequent graphs will fill the entire graph canvas.
plotClearLayout();
// 1. Clear all data from the GAUSS workspace.
// 2. Clear the current plot layout state, so that new graphs will fill the entire graph canvas.
new;

Example 2: Mixed Size Grid Layout

Sometimes your graphs will look better with tiles of different sizes. Fortunately, as we saw earlier, plotLayout only computes and stores coordinates.

Therefore, each call to plotLayout is independent of any previous calls. As long as your graph tiles do not overlap, each call to plotLayout may use a different grid size. This allows you to mix graphs of different sizes in the same graph canvas.

Let's modify our previous example, so that the third graph takes up the entire second row.

new;

// Create the vector 0.1, 0.2, 0.3...3.0
x = seqa(0.1, 0.1, 30);

/*
** First subplot
*/

// Divide the graph canvas into a 2x2 grid
// and place the next graph in the 1st cell
plotLayout(2, 2, 1);

// Create 'y1' and draw graph
y1 = exp(x);
plotXY(x, y1);

/*
** Second subplot
*/
plotLayout(2, 2, 2);

y2 = sin(x);
plotXY(x, y2);

/*
** Third subplot
**
**     Change to interpret the graph canvas
**     as a 2x1 grid and place the next graph
**     in the second cell.
*/
plotLayout(2, 1, 2);

y3 = cos(x);
plotXY(x, y3);

In this code example, we changed the inputs to plotLayout instructing it to:

  • Split the graph canvas into a grid with 2 rows and 1 column.
  • Place the next graph in the second cell.

This results in the graph below with the third plot taking up the entire second row of the graph canvas.

Tiled GAUSS graphs of different sizes.

Conclusion

Congratulations, you now have another tool in your graph creating toolbox! You have learned how to:

  1. Create tiled graphics in GAUSS.
  2. Create uniform and mixed size layouts.
  3. Clear the plot layout grid.

Next Steps

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 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy