Why does the data aspect ratio conflict with the axes size in a figure?

16 次查看(过去 30 天)
I set the data aspect ratio (axis equal, dbaspect, or DataAspectRatio property) to fix data distortion in the plot. Then I tried to adjust the axes position and shape in the window because I wanted to maximize the size of the axes in the figure. I also tried this in reverse, axes position and then the data aspect ratio.
However, once the data aspect ratio is set, the shape of the axes is changed and cannot be modified (even though the axes position can be changed). It also seems to disable interpretation of the Plot Box Aspect Ratio and the pbaspect function, as well as the X and Y Axis Limit properties and the XLim and YLim function.
This is frustrating and disappointing functionality, and is completely counter-intuitive. Why does setting the Data Aspect Ratio fix the axes shape? The Data Aspect Ratio has nothing to do with the shape of the axes. Resizing the viewport (axes) on the data should be possible regardless of the relative scale of the x and y coordinates in the view.
  1 个评论
Yazan
Yazan 2021-12-16
What do you mean by the "axes shape"? Other than the position, what do you want to change about the axes? Can you upload a sketch of what you are trying to achieve?

请先登录,再进行评论。

回答(1 个)

Nadia Shaik
Nadia Shaik 2022-2-2
Hi,
From my understanding you are not able to change the axis after setting the data aspect ratio. You can change the axis after setting data aspect ratio.
You can try the code below
x=linspace(-3*pi,3*pi);
y=sin(x);
plot(x,y)
daspect([1 1 1])
The result of the above code
As the data aspect ratio is [1 1 1], the relative data length among the x,y,z axis is equal.
When the axis is set
x=linspace(-3*pi,3*pi);
y=sin(x);
plot(x,y)
daspect([1 1 1])
axis([-4 4 -2 2])
The result of the above code
The data aspect ratio is still [1 1 1]. The axis however are modified as required.
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by