Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to let the axes in matlab have different lengths without changing axes limits

I'm trying to plot a 3D surface in Matlab and I want to "compress" the plot a little bit in the z dimension. Now the lengths of x, y and z axes are the same, and the plot looks like a cube. I'd like it to look flatter in the z dimension, without altering the axes limits.

Is there any easy way to achieve this?

like image 971
Vokram Avatar asked Dec 05 '25 16:12

Vokram


1 Answers

Try fiddling with the DataAspectRatio and the PlotBoxAspectRatio properties of the axes, which may also be controlled by the pbaspect and daspect commands, correspondingly.

Example

%// Plot surface
[X, Y] = meshgrid(-10:.1:10, -10:.1:10);
Z = 100 - X .^ 2 - Y .^ 2;
surf(X, Y, Z, 'EdgeColor', 'None')

%// Flatten the z-axis a bit
pbaspect([1 1 .2])
daspect([1 1 50])

Original plot:

enter image description here

Flattened plot:

enter image description here

like image 63
Eitan T Avatar answered Dec 08 '25 07:12

Eitan T



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!