How can I keep automatical adjustment of y-axis limits when manually zooming/using pan tool?
조회 수: 12 (최근 30일)
이전 댓글 표시
Hello,
Is there a possibility to keep the 'ylimmode' axes property set to 'auto' when manually zooming in/out or moving the graph in x-direction with the pan tool?
I defined a plot with specified limits of the x-axis and the 'ylimmode' property set to 'auto' (which is set by default anyway). E.g. like:
F = figure;
x = linspace(0,10*pi,1000);
signal = sin(t) + 0.07*randn(size(x));
h = plot(x,signal,'-x');
set(gca,'xlim', [2 3],'ylimmode','auto')
Whenever I scroll through the plot in x-direction using the pan tool in the property editor, 'ylimmode' property is set to 'manual' automatically. However, I want the limits of the y-axis to adjust automatically to the data when moving the graph from left to right. Is there a way to keep the 'ylimmode' property set to 'auto'?
Am looking forward for any comments. Thanks, Alex
댓글 수: 0
답변 (1개)
Richard
2015년 3월 5일
I was looking to have the y-axis limits reset while panning so that a time series curve was always within the plot window. Setting a callback from the pan event seems to work.
Creat the plot then set a callback on pan:
hpan = pan;
set(hpan,'Motion','horizontal','Enable','on');
set(hpan,'ActionPostCallback',@mypostcallback);
Now set YLimMode in the call back function:
function mypostcallback(obj,evd)
h = findobj(obj,'Type','axes');
set(h(:),'YLimMode','auto');
end
I wanted this to work for all subplots in the figure (obj) so used findobj. There is probably a better way to get the axes handles from the heirarchy but this seems to work.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!