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

16 Ansichten (letzte 30 Tage)
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 Kommentar
Yazan
Yazan am 16 Dez. 2021
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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Nadia Shaik
Nadia Shaik am 2 Feb. 2022
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!

Kategorien

Mehr zu Labels and Annotations finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by