Slider controls other axes

3 次查看(过去 30 天)
Mario
Mario 2014-1-24
I have a GUI with multiple axes. When the plot is very big, a scrollbar appears for controlling the plot. But when another plot is used, the slider controls it instead of the original plot. I think the problem is that for making the slider I use gca and gcf, but I do not know any other posibility.
For making the slider I used this function:
function scrollplot(dx,x,y)
% get current axes a=gca; % This avoids flickering when updating the axis set(gcf,'doublebuffer','on'); % Set appropriate axis limits and settings set(a,'xlim',[0 dx]); %set(a,'ylim',[min(y) max(y)]);
% Generate constants for use in uicontrol initialization pos=get(a,'position'); xmax=max(x); xmin=min(x);
% This will create a slider which is just underneath the axis % but still leaves room for the axis labels above the slider Newpos=[pos(1) pos(2)-0.12 pos(3) 0.05];
% Setting up callback string to modify XLim of axis (gca) % based on the position of the slider (gcbo) S=['set(gca,''xlim'',get(gcbo,''value'')+[0 ' num2str(dx) '])'];
% Creating Uicontrol with initial value of the minimum of x h=uicontrol('style','slider',... 'units','normalized','position',Newpos,... 'callback',S,'min',xmin,'max',xmax-dx,'value',xmin); %initialize postion of plot set(gca,'xlim',[xmin xmin+dx]);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by