Secondary vertical axis


I'm trying to obtain the time series graph of unemployment rate and GDP growth rates. Is there a way to have two y-axes with different scales to make comparison clear? Thank you for taking your time.


1 Answer


Yes, you can set two separate Y-axes. The GAUSS example file, plotts2.e, does this. You can run that file and examine the code.

As you see in that example file, you will need to use the function plotSetWhichYAxis to tell GAUSS which Y axis to associate the vectors with. Here is a small example:

// Declare 'myPlot' to be a plotControl
// structure and fill with default settings
struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

// Associate the first curve with the left Y axis
// and the second curve with the right Y axis
plotSetWhichYAxis(&myPlot, "left" $| "right");

// Set different labels for each Y axis
plotSetYLabel(&myPlot, "Left Y Axis" $| "Right Y axis");

// Create 2 Y-vectors with different scales
y1 = rndu(10,1);
y2 = rndu(10,1) * 100;
y = y1 ~ y2;

// Plot the 2 Y vectors as quarterly
// data starting 2005-Q1
plotTS(myPlot, 2005, 4, y);

You must login to post answers.

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