Clear Filters
Clear Filters

From plotyy towards plotxx

7 views (last 30 days)
Stefan
Stefan on 12 Feb 2015
Edited: Stefan on 19 Feb 2015
Dear reader,
I find plotyy(x,y1,x,y2) very useful mainly due to its ability to simultaneously execute pan/zoom on the 2 represented curves. Specifically, for my needs the x-axis is common while y1 and y2-axis are different. Here is an example:
figure;
x = linspace(0,2*pi,1e3);
y1 = sin(x);
y2 = 2*sin(x);
[AX,H1,H2] = plotyy(x,y1,x,y2); grid on;
set( get(AX(1),'XLabel'),'String','x-axis' );
set( get(AX(1),'YLabel'),'String','y1-axis' );
set( get(AX(2),'YLabel'),'String','y2-axis' );
Notice the x,y1,y2 coordinates get updated simultaneously , when the user pans/zooms on the figure: this is the functionality I am interested in. It allows me to zoom as much as I like on a specific region and precisely know what are the x,y1,y2 coordinates.
Question : how can I achieve the same result in terms of pan/zoom, in the situation where the y-axis is common while x1 and x2 are different? Specifically, this code does almost what I need:
figure;
x1 = linspace(0,2*pi,1e3);
x2 = x1 + 1;
y = sin(x1);
[AX,H1,H2] = plotyy(y,x1,y,x2); grid on;
set( get(AX(1),'XLabel'),'String','y-axis' );
set( get(AX(1),'YLabel'),'String','x1-axis' );
set( get(AX(2),'YLabel'),'String','x2-axis' );
set(AX(1), 'Ydir', 'reverse');
set(AX(2), 'Ydir', 'reverse');
view(-90,90);
This figure represents exactly what I need in terms of visualization of data, however I've lost the previous behavior (functionality) of pan/zoom. For instance when I try to pan, the entire figure moves like a block instead of only the data inside it. Any idea how to regain my pan/zoom functionality?
Thank you.

Answers (0)

Categories

Find more on View and Analyze Simulation Results in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!