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
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!