The Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: save figures without displaying
Replies: 28   Last Post: Feb 24, 2015 4:36 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Joe

Posts: 10
Registered: 8/29/14
Re: save figures without displaying
Posted: Aug 29, 2014 2:10 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Benjamin Avants" wrote in message <lddp9i$r70$1@newscl01ah.mathworks.com>...
> "Oliver" wrote in message <io6jkk$5em$1@fred.mathworks.com>...
> > Hi all, I've looked around for ages but cannot find a different solution. I fear there isn't one.
> >
> > Problem: I have a tool that batch processes data and creates loads (00's) of figures. I don't want them flashing up and getting in the way while the user is still trying to work on the machine.
> >
> > Current solution:
> > set(fig, 'visible','off')
> > saveas(fig,'file.fig','fig')
> > close(fig)
> >
> > This is fine, however when trying to open the saved .fig file they remain invisible.
> >
> > I tried....
> > set(fig, 'visible','off')
> > saveas(fig,'file.fig','fig')
> > set(fig, 'visible','on')
> > close(fig)
> >
> > In the hope it wouldn't be displayed, but it is.
> >
> > Next idea is to open the .fig using fopen and edit the file manually to set visibility to on, then re-save the edited .fig, but the data format is unknown.
> >
> > Any ideas how to save invisible figures, but have them open as visible?

>
> Jesse, you're solution is my favorite so far and I will be using it moving forward, but I have another for people who don't want to mess with the ResizeFcn.
>
> On my system, if I create the figure with visible off:
>
> fh = figure(...,'Visible','off');
>
> then build the content while the figure is invisible, I can then do the following:
>
> set(fh,'Visible','on');
> saveas(fh,'name','fig');
> delete(fh);
>
> This results in the figure being saved with visible enabled but the figure never shows up on my screen or takes focus away from whatever else I'm working on. I imagine this is because the figure is deleted before it can be fully rendered so it might not work on slower systems or when MATLAB is running multiple things simultaneously.
>
> If you're comfortable with setting/editing the ResizeFcn, that's a more robust solution.


Jessie's

figure2 = figure
set(figure2, 'visible','off')
set(figure2,'ResizeFcn','set(gcf,''visible'',''on'')');
saveas(figure2,'name','fig');

worked for me too.

I had one thing that didn't work though. One of my figures had subplots in it with a lot of re-positioning and modifications. This figure followed the code (did not pop open and saved correctly, but when I tried to double click it in the windows folder, it did not open.

What fixed this has adding a

set(figure2,'Visible','on')

right after the

set(figure2,'ResizeFcn','set(gcf,''visible'',''on'')');

followed by the save function and the close all windows.

Don't know why the ResizeFcn didn't turn this plots with subplots back to visible, but what I've got right now is working great!


Date Subject Author
4/14/11
Read save figures without displaying
Oliver
4/14/11
Read Re: save figures without displaying
Grzegorz
4/14/11
Read Re: save figures without displaying
Oliver
4/14/11
Read Re: save figures without displaying
John
4/14/11
Read Re: save figures without displaying
Grzegorz
4/14/11
Read Re: save figures without displaying
Yuri Geshelin
4/19/11
Read Re: save figures without displaying
Oliver Woodford
4/20/11
Read Re: save figures without displaying
Yuri Geshelin
10/30/12
Read Re: save figures without displaying
Lisa Thierbach
12/13/12
Read Re: save figures without displaying
Tor Inge Birkenes
12/13/12
Read Re: save figures without displaying
Steven Lord
12/13/12
Read Re: save figures without displaying
Yuri Geshelin
12/14/12
Read Re: save figures without displaying
Tor Inge Birkenes
12/13/12
Read Re: save figures without displaying
Yuri Geshelin
11/1/13
Read Re: save figures without displaying
Julian
11/22/13
Read Re: save figures without displaying
Bo Zhang
2/11/14
Read Re: save figures without displaying
Benjamin
8/29/14
Read Re: save figures without displaying
Joe
9/2/14
Read Re: save figures without displaying
Joe
1/29/15
Read Re: save figures without displaying
Erik
1/29/15
Read Re: save figures without displaying
Yuri Geshelin
1/30/15
Read Re: save figures without displaying
Erik
1/30/15
Read Re: save figures without displaying
Yuri Geshelin
1/30/15
Read Re: save figures without displaying
Marco
1/30/15
Read Re: save figures without displaying
Yuri Geshelin
1/31/15
Read Re: save figures without displaying
Yuri Geshelin
2/2/15
Read Re: save figures without displaying
Marco
2/3/15
Read Re: save figures without displaying
Yuri Geshelin
2/24/15
Read Re: save figures without displaying
Joe

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2017. All Rights Reserved.