Control figure visibility outside of a function

2 次查看(过去 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?

回答(2 个)

Image Analyst
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.

Walter Roberson
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.

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by