Axis equal plot in multiple axes GUI

조회 수: 1 (최근 30일)
Elando
Elando 2016년 7월 19일
댓글: Adam 2016년 7월 19일
Hello everybody,
I have a question for you! I have made a code that creates a figure (that initially is invisible) with two axes; in one of the two axes I plot a circle and I need to make this axes with axis equal.
I found on the internet the command axes(..); axis equal, but if I run the code with debugger I saw that when Matlab executes this command, it make the figure visible and I don't need it.
I would need something that make the axis equal, but without showing the figure until the very end of the code when I make it visible; is it possible? Thank you
Here is a simple example that show what happen:
function sample()
f = figure('Visible','off','Position',[300,500,700,500]);
ha = axes('Units','pixels','Position',[50,50,200,400]);
ha_1 = axes('Units','pixels','Position',[300,50,300,400]);
% plot in ha
r = 60;
th = 0:pi/50:2*pi;
x = r*cos(th');
y = r*sin(th');
plot(ha,x,y)
axes(ha); axis equal
f.Units = 'normalized';
f.Visible = 'on';
end

답변 (1개)

Adam
Adam 2016년 7월 19일
편집: Adam 2016년 7월 19일
The documentation for the
axis equal
command states that the following axes properties change:
'Sets DataAspectRatio to [1 1 1], sets PlotBoxAspectRatio to [3 4 4], and sets the associated mode properties to manual.'
So you could just set
ha.DataAspectRatio = [1 1 1];
ha.PlotBoxAspectRatio = [3 4 4];
and if it doesn't already do it by doing that ( I can't remember) set
ha.DataAspectRatioMode = 'manual';
ha.PlotBoxAspectRatio = 'manual';
too.
To be honest that specific PlotBoxAspectRatio is a bit of a mystery to me, but that is what it says and I never really play around with those settings to have bothered to learn exactly what that does.
  댓글 수: 1
Adam
Adam 2016년 7월 19일
Alternatively you could just do
axes(ha); axis equal; f.Visible = 'off'
but that is rather ugly - letting it switch the figure visibility on and then over-riding it to switch it off again. It is possible that the user may see this happen too - I haven't tried it, maybe it happens fast enough that the user doesn't see a flicker. I have done it successfully in similar cases.

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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by