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

76 views (last 30 days)
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')

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
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')

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2007a

Community Treasure Hunt

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

Start Hunting!