필터 지우기
필터 지우기

How can I keep figures invisible when toggling between axes?

조회 수: 4 (최근 30일)
Jennifer Davies
Jennifer Davies 2017년 11월 15일
댓글: Jennifer Davies 2017년 11월 16일
If I create figures using the following code
for fig=1:2
figure('papertype','A4','paperorientation','portrait','Visible','Off')
for sp=1:6
ax{fig,sp}=subplot(3,2,sp,'parent',fig);
end
end
I can then toggle between the subplots using axes, e.g., to get to subplot 4 on figure 2 I use
axes(ax{2,4})
But this makes the figure visible. Does anyone know if there's a way to keep it invisible please?
Thanks in advance for your help! Jen

답변 (2개)

Rik
Rik 2017년 11월 15일
You can either use the obvious solution/workaround of calling set(gcf,'Visible','off') immediately after that line, or just avoid that line in the first place. Just about every function I can think of will accept a target axis instead of using the current axis as default.

Walter Roberson
Walter Roberson 2017년 11월 15일
Calling axes() should not cause the figure to become visible unless the axes() call is creating a new figure.
Instead of calling axes to make an axes the current axes, you can
for fig=1:2
figs(fig) = figure('papertype','A4','paperorientation','portrait','Visible','Off');
for sp=1:6
ax{fig,sp} = subplot(3, 2, sp, 'parent', figs(fig));
end
end
and later
set(figs(2), 'CurrentAxes', ax{2, 4})
But as Rik suggests, you can mostly rewrite to pass an axes in to graphics commands, either as the first parameter or using 'Parent' . There are some calls that you cannot do this for, especially when it comes to things like bode plots, or trying to pre-create both axes for use with plotyy()
  댓글 수: 1
Jennifer Davies
Jennifer Davies 2017년 11월 16일
Thanks Walter. I have just changed
axes(ax{2, 4})
to
set(gcf, 'CurrentAxes', ax{2, 4})
and this seems to work great. Thanks!

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

카테고리

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