Slider controls other axes

9 views (last 30 days)
Mario
Mario on 24 Jan 2014
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]);

Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!