Slider controls other axes

3 visualizzazioni (ultimi 30 giorni)
Mario
Mario il 24 Gen 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]);

Risposte (0)

Categorie

Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by