what 's different between axis square and axis equal in matlab ?

조회 수: 195 (최근 30일)
Nguyen Trong Nhan
Nguyen Trong Nhan 2014년 5월 27일
댓글: John D'Errico 2025년 4월 29일
when I plot or surf, what's different between axis square and axis equal ?

채택된 답변

Mahdi
Mahdi 2014년 5월 27일
From this page:
axis equal sets the aspect ratio so that the data units are the same in every direction. The aspect ratio of the x-, y-, and z-axis is adjusted automatically according to the range of data units in the x, y, and z directions.
axis square makes the current axes region square (or cubed when three-dimensional). This option adjusts the x-axis, y-axis, and z-axis so that they have equal lengths and adjusts the increments between data units accordingly.

추가 답변 (1개)

Narin Deveci
Narin Deveci 2020년 10월 30일
Do you know the formula to set your axes to be square?
  댓글 수: 5
Muhammad Safdar
Muhammad Safdar 2020년 11월 23일
Hi, I have a 3D plot, I set axis([-100 100 -80 120 -50 150]) followed by axis equal. That means I have equal range of data in all directions and figure should look like a cube but hight looks larger than bottom witdhs on my screen? why?
John D'Errico
John D'Errico 2025년 4월 29일
Remember that a figure window, as created by default in MATLAB is not square. So even though you set the axis limits to have a distance of 200 from min to max on each axis, the result will not look like a cube, because each axis will then be scaled to fit into the rectangular box of the figure.
We can see this quite well using the function sphere. If I just call sphere, it will generate a nicely spherical shape, but it won't look like a sphere. Instead, you will see an oblate sphereoid.
sphere
Instead, if I set the axes to have equal units on each axis, (using the command "axis equal"), we will see the same thing, but now it will look sphereical.
figure
sphere
axis equal
Exactly the same thing happens when you tried to plot a cube. For example...
XYZ = rand(10000,3); % some data that lives inside the unit cube
Plotting the data in a set of default axes, it will not appear as if it lives in a cube.
plot3(XYZ(:,1),XYZ(:,2),XYZ(:,3),'.')
box on
But now, if I tell MATLAB this should live in a domain with equal scaling on the axes, we will see it as living inside a cubical domain.
figure
plot3(XYZ(:,1),XYZ(:,2),XYZ(:,3),'.')
axis equal
box on

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by