How can I use the AXIS EQUAL functionality for a 3D plot in MATLAB 7.4 (R2007a) ?

조회 수: 79 (최근 30일)
I would like to be able to make an option in the ‘axis equal’ functionality to select 2 axes only and have the third axis scaled automatically. The following code shows that the ‘axis equal’ functionality doesn’t scale the figure properly:
figure
t = 0:pi/50:10*pi;
subplot(1,2,1); plot3(sin(t),cos(t),t);
title('Normal');
subplot(1,2,2); plot3(sin(t),cos(t),t);
axis equal;
title('Axis equal')

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
The ability to use the AXIS function for 3-D plots is not available in MATLAB.
To work around the issue, it is possible to scale all the three axes by using the 'DataAspectRatio' property of the axes object:
figure
t = 0:pi/50:10*pi;
subplot(1,2,1); plot3(sin(t),cos(t),t);
title('Normal');
subplot(1,2,2); plot3(sin(t),cos(t),t);
h = get(gca,'DataAspectRatio')
if h(3)==1
set(gca,'DataAspectRatio',[1 1 1/max(h(1:2))])
else
set(gca,'DataAspectRatio',[1 1 h(3)])
end
title('Axis equal')

추가 답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2007a

Community Treasure Hunt

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

Start Hunting!

Translated by