Vokram
Vokram

Reputation: 2127

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?

Upvotes: 3

Views: 1097

Answers (1)

Eitan T
Eitan T

Reputation: 32930

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

Upvotes: 3

Related Questions