# Different scales for two separate y-axis

I am plotting a graph with two separate y-axis and would like a different scale on each y-axis. The left axis from 3 to 5, the right from 0 to 1.

The following code does not put the correct scale on either axis:

``````struct plotControl cogra;
cogra = plotGetDefaults("xy");
plotSetWhichYAxis(&cogra, "left" \$| "right");
plotSetYRange(&cogra, 3|0, 5|1);
plotSetYTicInterval(&cogra, 0.1, 3);
plotSetYTicCount(&cogra, 1);
plotXY(cogra,dates,y~x);``````

Replacing

``plotSetYRange(&cogra, 3|0, 5|1);``

with

``plotSetYRange(&cogra, 3, 5);``

puts the correct scale on the left axis only.

0

I tested this code in GAUSS 22 and GAUSS 23 and I get the graph linked at the bottom with correct y-axes.

``````new;
cls;

rndseed 542345;

nobs = 30;
x = seqa(1, 1, nobs);
y = (3 + rndn(nobs, 1)) ~ rndu(nobs, 1);

struct plotControl plt;
plt = plotGetDefaults("xy");

plotSetWhichYAxis(&plt, "left"\$|"right");

/*
** Set the range for the left y-axis to 3-5,
** and the range for the right y-axis to 0.5 to 1.5
*/
plotSetYRange(&plt, 3|0.5, 5|1.5);

/*
** Place tick marks for the:
**     left y-axis every 0.3, starting at 3 (i.e. 3.0, 3.3, 3.6, ...)
**     right y-axis every 0.1, starting at 0.6 (i.e. 0.6 0.7, 0/8, ...)
*/
plotSetYTicInterval(&plt, 0.3|0.1, 3|0.6);

plotXY(plt, x, y);``````

aptech

1,773

0

I tested this code in GAUSS 22 and GAUSS 23 and I get the graph linked at the bottom with correct y-axes.

``````new;
cls;

rndseed 542345;

nobs = 30;
x = seqa(1, 1, nobs);
y = (3 + rndn(nobs, 1)) ~ rndu(nobs, 1);

struct plotControl plt;
plt = plotGetDefaults("xy");

plotSetWhichYAxis(&plt, "left"\$|"right");

/*
** Set the range for the left y-axis to 3-5,
** and the range for the right y-axis to 0.5 to 1.5
*/
plotSetYRange(&plt, 3|0.5, 5|1.5);

/*
** Place tick marks for the:
**     left y-axis every 0.3, starting at 3 (i.e. 3.0, 3.3, 3.6, ...)
**     right y-axis every 0.1, starting at 0.6 (i.e. 0.6 0.7, 0/8, ...)
*/
plotSetYTicInterval(&plt, 0.3|0.1, 3|0.6);

plotXY(plt, x, y);``````

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.