Set default visibility of figures to 'on' not working!
91 次查看(过去 30 天)
显示 更早的评论
Hello,
I am using set(0,'DefaultFigureVisible','off') to hide figures that are created during my script. I want to plot things afterwards and doing the obvious set(0,'DefaultFigureVisible','on') does not seem to do the trick. I cannot display any plots after my code runs. I've tried taking it out of the loop its in and the function, but nothing seems to work. I've seen this post: https://www.mathworks.com/matlabcentral/answers/223980-how-to-set-figure-plot-visibility-to-on-by-default, but the answers were not helpful. The one that suggests to use setpref could be helpful if someone could tell me how to just restore default settings, but that also seems like overkill.
Does anyone know how to set figure visibility to 'on' after setting it to 'off' previously?
Thanks,
Eric
2 个评论
Adam
2018-3-7
Setting the Default property only affects figures created after that point.
To set visibility of existing ones just keep the figure handles for all the ones you create in an array and use
set( hFigs, 'Visible', 'on' )
where hFigs is your array of existing invisible figures.
Thiago Azevedo
2022-4-7
I know I am replying almost four years later, but I will do so for those who are encountering the same problems I did: figures saved with the 'DefaultFigureVisible', 'off'.
To add on this answer, if you save the figure after the command set(0,'DefaultFigureVisible','off'), the figure is saved with this setting. So everytime you try to open a .fig file, it won't open unless you perform something like:
hFigs = openfig(figurepath);
set(hFigs,'Visible','on');
To avoid needing to do so, you might want to save the figure after setting it back 'on' with set(hFigs, 'Visible', 'on'), such that the 'Visible' property is kept as 'on' for that figure even after closing it and opening again in another session. Else, the saved figure will simply return to its then set default visibility status 'off' once it's closed.
Cheers.
回答(2 个)
Jan
2018-3-7
It does work:
set(groot, 'DefaultFigureVisible', 'off')
figure('Name', 'not visible')
set(groot, 'DefaultFigureVisible', 'on')
figure('Name', 'visible')
Maybe you do something like this:
set(groot, 'DefaultFigureVisible', 'off')
figure(1)
set(groot, 'DefaultFigureVisible', 'on')
figure(1)
But then the second figure command does not open a new figure.
I cannot try this currently, so please run it and post, what you observe.
3 个评论
Jan
2019-3-20
Since Matlab R2014a the new Graphics Engine "HG2" is used. With "HG1" the graphic handles have been doubles and 0 was the root object. In HG2 the handles are a specific class, which helps to avoid confusions with numbers. For backward compatibility accessing 0 as root object is still supported, but groot is smarter.
For Backward compatibility I include a folder in the path for old Matlab versions, which contain e.g. this function:
function H = groot
H = 0;
So I can use groot in all of my codes, even if they run under R2009b.
Anian Roppel
2018-3-7
Close the invisible figures created in your script (close all) and use set(0,'DefaultFigureVisible','on')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!