Slider controls other axes
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!