Why does the data aspect ratio conflict with the axes size in a figure?
18 ビュー (過去 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
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
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/881795/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/881800/image.png)
The data aspect ratio is still [1 1 1]. The axis however are modified as required.
Hope it helps!
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!