Control figure visibility outside of a function
조회 수: 3 (최근 30일)
이전 댓글 표시
I have 10 figures, I wanna control their visibility. I did the following to set visibility for each figure. These figures belongs to 5 different functions. Hence, whenever I wanna change the display of figure (for example, I wanna display 1,5,9 now, later I wanna display something else, say 2,5,8), I need to edit/change the function itself.
h1 = figure(1); imshow(edge)
set(h1, 'Visible','Off')
any suggestion how to control the visibility without editing those function, i.e. writing a script or something like that to control which figure number to display?
댓글 수: 0
답변 (2개)
Image Analyst
2015년 5월 23일
You didn't say how it was to be decided which figures would be displayed or hidden. For example, you could have a GUI with 10 checkboxes on it, where the user can check which figures he wants displayed. The callback of the checkbox would run your code to show or hide the figures.
댓글 수: 0
Walter Roberson
2015년 5월 23일
function showfigure(fignum)
set(fignum,'Visible', 'off');
end
function hidefigure(fignum)
set(fignum,'Visible', 'off');
end
Now you can showfigure(5); hidefigure(7);
You can even set things up like this
function showfigures(fignums)
tohide = setdiff(1:10, fignums); %1:10 reflects the 1 through 10 you used
set(fignums, 'visible', 'on');
set(tohide, 'visible', 'off');
end
and then you can showfigures([1,5,9]) to have it turn on 1, 5, 9 and turn off the others.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!