フィルターのクリア

How can I keep automatical adjustment of y-axis limits when manually zooming/using pan tool?

17 ビュー (過去 30 日間)
Alexander
Alexander 2013 年 3 月 10 日
回答済み: Richard 2015 年 3 月 5 日
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

回答 (1 件)

Richard
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.

カテゴリ

Help Center および File ExchangeData Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by