axis equal - a bug in the function?

Hi,
when executing following
plot(1:10)
axis equal
I'm getting a figure as below, which seems not to comply with the definition of the equal: "Use the same length for the data units along each axis"

回答(2 个)

Peter Nave
Peter Nave 2020-12-26
The units ARE the same, take a ruler and measure them on the monitor!
Bruno Luong
Bruno Luong 2020-12-26
编辑:Bruno Luong 2020-12-26
It is. The unit length is the same, not the total length of the axis.
If you want to enforce the limits use xlim/ylim commands after axis equal.

6 个评论

So it is not clear to me what is the difference comparing to
plot(1:10)
Matlab adjusts the plot limits covers your data. The command "axis equal" does not touch the axis limits so that they are equal.
All it warranty is the aspect ratio: 1 unit of xaxis == 1 unit of yaxis when rendering on the screen. (unit length)
"So it is not clear to me what is the difference comparing to "
Not much because your X and Y data ranges are the same. If you plotted some data with different X and Y ranges the equal unit length set by axis equal would be much clearer (note that MATLAB automatically fits the entire data range to within the axes whilst keeping the unit lengths the same):
X = 0:10;
Y = 2*X;
plot(X,Y,'-*')
axis equal
Rest my case - you have same issue. The scale is 20, but on your x axis, you have more than 20 points.
"you have same issue"
No he has not. You simply fail to understand what "axis equal" does despite of three people telling you what it suppose to do.
You are stuck in your onw logic which is NOT "axis equal" supposes to do.
"Rest my case - you have same issue. The scale is 20, but on your x axis, you have more than 20 points."
The axis documentation does not state anything about how many units (i.e. the range) will be displayed for each of the axes, it only defines that their unit lengths will be the same: "equal Use the same length for the data units along each axis." For some reason you seem to be confusing the data range with unit length.
The statement "you have more than 20 points." is in any case incorrect: there are exactly eleven data points plotted on the axes in my previous comment (I just added a marker so that everyone can count them).

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Line Plots 的更多信息

产品

版本

R2020b

标签

提问:

2020-12-26

编辑:

2020-12-26

Community Treasure Hunt

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

Start Hunting!

Translated by