help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: figures not saved inside loop


From: andre valente
Subject: RE: figures not saved inside loop
Date: Tue, 30 Jun 2015 12:06:56 +0000


> Date: Tue, 30 Jun 2015 13:11:01 +0200
> Subject: Re: figures not saved inside loop
> From: address@hidden
> To: address@hidden
> CC: address@hidden; address@hidden
>
> On Tue, Jun 30, 2015 at 12:19 PM, andre valente <address@hidden> wrote:
> >> Date: Tue, 30 Jun 2015 12:01:16 +0200
> >> Subject: Re: figures not saved inside loop
> >> From: address@hidden
> >> To: address@hidden
> >> CC: address@hidden; address@hidden
> >>
> >> On Tue, Jun 30, 2015 at 11:57 AM, andre valente <address@hidden>
> >> wrote:
> >> > The problem is quite simple. For example the code below, sometimes saves
> >> > all
> >> > the figures, sometimes it doesn't. This is not my regular machine, so I
> >> > guess the problem is with the machine and not with octave.. anyway I
> >> > would
> >> > be very happy to fix this problem.
> >> >
> >> > a=rand(100,20);
> >> > for i=1:20;
> >> > figure;plot(a(:,i));
> >> > outname=strcat('figure_',num2str(i));
> >> > eval(['print -dpng ',outname]);
> >> > close;
> >> > end
> >> >
> >> >
> >> >> Date: Mon, 29 Jun 2015 21:44:06 +0200
> >> >> Subject: Re: figures not saved inside loop
> >> >> From: address@hidden
> >> >> To: address@hidden
> >> >> CC: address@hidden; address@hidden
> >> >>
> >> >> On Mon, Jun 29, 2015 at 8:05 PM, andre valente
> >> >> <address@hidden>
> >> >> wrote:
> >> >> > Hello,
> >> >> >
> >> >> > I have a loop quite fast (not sure this is part of the problem)
> >> >> > making
> >> >> > plots
> >> >> > and saving them as png's. Some of the figures are not saved. I made
> >> >> > some
> >> >> > tests, and appears to be random.. sometimes it saves, other times it
> >> >> > doesn't. They pop-up as figures, but just are not saved. Is this
> >> >> > normal?
> >> >> > It
> >> >> > is quite a problem for me.. Hope you can help. Thanks.
> >> >> >
> >> >> > I am using version 3.8.2 for x86_64-redhat-linux-gnu .
> >> >> >
> >> >> > Regards,
> >> >> > Andre
> >> >> >
> >> >> > _______________________________________________
> >> >> > Help-octave mailing list
> >> >> > address@hidden
> >> >> > https://lists.gnu.org/mailman/listinfo/help-octave
> >> >> >
> >> >>
> >> >> I do not have this problem. Could you share your test code to see if
> >> >> we can reproduce.
> >>
> >> Try,
> >>
> >> figure (1);
> >> outname = @(x) sprintf ("figure_%d.png", x)
> >> a = rand (100,20);
> >> for i = 1:20;
> >> clf;
> >> plot (a(:,i));
> >> print ("-dpng",outname (i));
> >> end
> >>
> >> If it doesn't work: What is the output of
> >>
> >> graphics_toolkit
> >>
> >> ?
> >>
> >> PS: Please answer at the bottom of the message as I am doing here.
> >
> > Ok, I tried 4 times and saved all figures. So it appears to work. What do
> > you think was the problem with my script? Or the solution with yours?
> It might be that creating the figure inside the loop was not working
> correctly. It might also be the reason for "speed": figures weren't
> created.
> > The "clf" before the figure?
> You can use drawnow instead.
> > Opening a figure before?
> > How you defined outname.. ?
> it is just a function handle, I wanted to remove everything out of the
> plot. you cna use your version if you prefer.
> > Also noticed your script was much slower.
> How much? How do you benchmark?
>
> >
> >


Thank you all for the help. As for the drawnow, it does not work for me.. there are still figures not saved. But, by opening a figure beforehand, and "clf" before any plot, appears to resolve the problem.  I will apply last method to my scripts and hope I will recover from this soon :) (i.e. stop re-checking every time what was done).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]