Control figure visibility outside of a function

1 view (last 30 days)
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?

Answers (2)

Image Analyst
Image Analyst on 23 May 2015
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 on 23 May 2015
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.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!