Changing x and y limits when using plotyy

I am using the guide and have a problem when trying to change the limits of the axes with two lines.
I have these sets of data: x, y1, y2
I have plotted them using the plotyy command:
[AX, h1, h2] = plotyy(x,y1,x,y2)
This occurs in one function.
A separate function controls changing the axes limits. In this example, I want to 'pan up' by adding a tenth of the variable 'ylimsd' to the y-limits.
ylims = ylim;
ylims1 = ylims(1,1);
ylims2 = ylims(1,2);
ylimsd = ylims2 - ylims1;
Problem --> if I use:
ylim(gca, ylim + (ylimsd/10))
only the line containing (x,y1) is affected, and the other line appears to be frozen and unaffected.
Is there any way I can 'pan' so that both lines move together?
P.S. I realise if I were to set the y limits immediately after the plotyy (i.e. in the same function) I could use the following code:
set(AX(1),'Ylim',ylim + (ylimsd/10))
set(AX(2),'Ylim',ylim + (ylimsd/10))
BUT I am trying to 'pan' from a separate function, so 'AX' is undefined.

 Accepted Answer

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!