Call to Subplot is Adding Axis to Current Figure
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm creating a figure and then later adding a subplot to it. When I get the axis handle from the call to subplot, it is adding an axis to what I think is the current figure.
%pre-allocate graphics objects for holding figures
figs = gobjects(2,1);
%create figures and store in variable figs
for i1 = 1:length(figs)
figs(i1) = figure;
end
%create the upper axis of a 2x1 subplot and get the handle
%this call is also adding an axis to figs(2) for some reason
ax = subplot(2,1,1,'Parent',figs(1))
If I add a call to
set(0,'CurrentFigure',figs(1))
just before
ax = subplot(2,1,1,'Parent',figs(1))
then it won't create an axis on the second figure. Can anyone explain this phenomenon? Is there a better solution than my workaround of having to set the current figure before any of these calls?
댓글 수: 4
채택된 답변
Adam
2019년 4월 10일
Yes, that does seem a slightly odd thing to have in the startup file and is indeed the cause of this behaviour (I just tested with and without it).
I have the first line in my startup file also, but not the second line.
Try replacing that line with the following in your startup instead:
set(groot,'defaultAxesCreateFcn',@(ax,~)set(ax.Toolbar,'Visible','off'))
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!