Pan a Plotted Curve with a Stationary Plot Behind

조회 수: 1 (최근 30일)
Harry MacDowel
Harry MacDowel 2011년 10월 18일
figure;
X = rand(100,1);
Y = rand(100,1);
plot(X,Y);
hold on;
plot(X,sin(Y));
I want to be able to pan the sine curve ONLY. The sine curve can move around the plot but the first plot remain STATIONARY behind.
I wanna do this because I need to just merely compare the shape of the sine curve to the plot behind.
I remember I used to do this before using plotyy or something but I forgot how I achieved that. Anyone has any idea?
Many thanks! =D
  댓글 수: 1
Harry MacDowel
Harry MacDowel 2011년 10월 19일
Just wanna push this up again coz I still can't find a solution for this. Thanks!

댓글을 달려면 로그인하십시오.

채택된 답변

Daniel Shub
Daniel Shub 2011년 10월 19일
I cannot get it to easily work with plotyy, but I think with some work you could. That said, I am not sure there is a real advantage.
X = rand(100,1);
Y = rand(100,1);
minX = min(X);
maxX = max(X);
minY = max([min(Y), min(sin(Y))]);
maxY = max([max(Y), max(sin(Y))]);
figure;
hax(1) = axes;
plot(X, Y, 'b');
axis([minX, maxX, minY, maxY]);
hax(2) = axes;
plot(X, sin(Y), 'r');
axis([minX, maxX, minY, maxY]);
h = pan;
setAllowAxesPan(h, hax(1), false);
set(hax(2), 'Visible', 'Off');
  댓글 수: 1
Harry MacDowel
Harry MacDowel 2011년 10월 19일
Nice work Daniel! Last time I guess I can achieve that trick because I was working with axes in GUI and I return the figure handle to the GUI window. Somehow.
But seriously, thank you! +1 vote

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by