Azzera filtri
Azzera filtri

how to save multiple figure without displaying

7 visualizzazioni (ultimi 30 giorni)
I'm working on a code that repeating plot data to different figure. below is a test code:
clear
clc
for j=1:3
h1=figure(1);
x=0:0.01:1;
y=x.*j;
plot(x,y);
set(h1,'visible','off');
h2=figure(2);
x=0:0.01:1;
y=x.*j;
plot(x,y);
set(h2,'visible','off');
h3=figure(3);
x=0:0.01:1;
y=x.*j;
plot(x,y);
set(h3,'visible','off');
end
the problem is that the figure is blinking on the screen.
I read some answer in forum, such as:
f = figure('visible', 'off');
however, in my situation, I need to plot multiple figure, is there anyway to set the figure invisible since it is created? for example I want to make figure(2) invisible, the code like is:
f = figure(2, 'visible', 'off');
thanks!
Li
  3 Commenti
Yu Li
Yu Li il 3 Mar 2017
hi; looks this is a good ideal. let me have a try! thanks! Li
John BG
John BG il 4 Mar 2017
Yu Li
happy to help.
there is no way to tell plot to go 'invisible' once you invoke it.
it's like telling a bullet not to leave the barrel once the pin has pierced it.
Would you please be so kind to consider marking my answer as accepted answer?
I have copied my comment as answer that you and other people in the forum may find useful.
If you mark my answer as accepted I get 4 credit points.
Thanks in advance for time and attention, awaiting answer
John BG

Accedi per commentare.

Risposta accettata

John BG
John BG il 4 Mar 2017
Yu Li
why don't you just save the variables, [x,y] for each plot BEFORE plotting in a .mat file?
if you find this answer useful would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG

Più risposte (3)

Rik
Rik il 2 Mar 2017
You can't combine the attributes with the number syntax at figure creation, so you'll have to use your current solution. If you try h1=figure(1);ax1=gca;set(h1,'visible','off');plot(ax1,x,y), plot(ax1,x,y) will set the figure to visible.
If you need to go for invisible, you can always do something like set(h,'OuterPosition',[-0 0 eps eps]). You will probably be stuck some of that time with the figures stealing focus, but I think it is you best bet. This will also probably mess up some of the thing you might want to do with these plots.

Walter Roberson
Walter Roberson il 3 Mar 2017
fig(1) = figure(1);
ax(1) = axes('Parent', fig(1));
fig(2) = figure(2);
ax(2) = axes('Parent', fig(2));
fig(3) = figure(3);
ax(3) = axes('Parent', fig(3));
for j=1:3
x=0:0.01:1;
y=x.*j;
if j == 1
p(1) = plot(ax(1), x, y);
else
set(p(1), 'XData', x, 'YData', y);
end
x=0:0.01:1;
y=x.*j;
if j == 1
p(2) = plot(ax(2), x, y);
else
set(p(2), 'XData', x, 'YData', y);
end
x=0:0.01:1;
y=x.*j;
if j == 1
p(3) = plot(ax(3), x, y);
else
set(p(3), 'XData', x, 'YData', y);
end
drawnow();
end

Y. J.
Y. J. il 26 Lug 2018
Modificato: Y. J. il 26 Lug 2018
Hey guys maby u can help me with my problem too... . I think it is a small addon to the code before
Im doing something like:
f(1) = figure('visible', 'off');
ax(1) = axes('Parent', f(1));
while(some condition)
load some data;
plot(ax(1),x.Torque1cNm, y.Speed1RPM,'DisplayName', N);
xlabel('Torque [cNm]');
ylabel('Speed [rpm]');
title('Torque vs Speed');
legend('-DynamicLegend');
hold all
end
saveas(f(1), 'xxxx', 'png');
(Lets assume i plot two line in that figure) The second one overwrites the first and there is no legend no grid no title or axis labeling. What im doing wrong?
Edit:
Sorry that is not the complete information. In this case it works but in my real code im opening 20 different figure and i think they overwriting each other. What can I do in this case? because i can´t write smth. like
figure(1,'visible', 'off')

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by