Why does an empty duplicate figure box appear?

조회 수: 12 (최근 30일)
Yasmin Samy
Yasmin Samy 2017년 10월 17일
댓글: Yasmin Samy 2017년 10월 17일
Below is part of a code that i am using to plot some scatter plots. The problem is that for every loop i am getting two plots. The first is the required graph and the second is just a figure box. Unfortunately, that empty figure duplicate gets saved.
I don`t know what am i doing wrong.
if i=length(A)
if i==3
set(figure,'position',[0, 0, 800, 250]);
plotdaily = scatter(dat,variable,[],black,'filled');
hold on
plotdaily2=scatter(dat2,variable2,'MarkerFaceColor',gray,'MarkerEdgeColor',gray,...
'MarkerFaceAlpha',.4,'MarkerEdgeAlpha',.4)
box on
title('Total AOD at Eureka');
elseif i ==4
set(figure,'position',[0, 0, 800, 250]);
plotdaily = scatter(dat,variable,[],red,'filled');
hold on
plotdaily2=scatter(dat2,variable2,'MarkerFaceColor',pink,'MarkerEdgeColor',red,...
'MarkerFaceAlpha',.4,'MarkerEdgeAlpha',0.4);
box on;
title('Fine AOD at Eureka');
grid on
saveas(figure, sprintf('Daily_Average%d.jpg',i))
end
end

채택된 답변

Walter Roberson
Walter Roberson 2017년 10월 17일
In your code, replace all references to figure to become gcf
  댓글 수: 1
Yasmin Samy
Yasmin Samy 2017년 10월 17일
Thanks Walter! i had to add 'figure' in the elseif though because the next plot was done on the first one when i didn`t. [every iteration plots from a different loop]. Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by