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

조회 수: 19 (최근 30일)
William Rosenthal 2021년 12월 14일
답변: Nadia Shaik 2022년 2월 2일
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이전 댓글 -1개 표시이전 댓글 -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개)

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에서 2-D and 3-D Plots에 대해 자세히 알아보기

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by