Supress image showing until called on Live Script

4 views (last 30 days)
I essentially want to create figures on the livescript, but not have them show up on the output location until called on later. As in, create and edit all of the plots first, assign figure number/labels to them, but only have them appear on the output line when called on in a "discussion" section at the end of the livescript.
I have tried using what is usually suggested, which I assume works well for normal scripts:
% and later on
However, the figures still show up on the output line. The only solution I have found is using 'close(fig_label)', but it doesn't seem like I can re-open the figure later.
I assume a solution is creating functions for each individual plot, but I was hoping for something a bit more elegant than that.
Thank you.

Answers (1)

Maximilian Schönau
Maximilian Schönau on 3 Jan 2021
Edited: Maximilian Schönau on 3 Jan 2021
A quite simple workaround would be, if you save the figure you want to be invisible, then close it and open it again from a file when you need it:
% Example Plot
xlabel Test
savefig myfigure.fig
close gcf
% do some work
x = 1;
y = 2;
% now open plot again
open myfigure.fig


Find more on Printing and Saving 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!