Back to Data Visualization

view

Set 3D view angle

Syntax

view(az, el)
view([az el])
view(2)
view(3)
[az, el] = view

Description

Sets the camera viewing angle for 3D plots (mesh, surf). Azimuth is the angle of rotation around the z-axis measured from the negative y-axis (counterclockwise positive). Elevation is the angle from the x-y plane (-90 to 90 degrees). view(2) sets a top-down 2D view (az=0, el=90). view(3) sets the default 3D view (az=-37.5, el=30).

Parameters

NameDescription
az(optional)Azimuth angle in degrees
el(optional)Elevation angle in degrees

Returns

With no arguments, returns [az, el] of current view

Examples

Try It
>> [X, Y] = meshgrid(-2:0.2:2);
Z = X .* exp(-X.^2 - Y.^2);
surf(X, Y, Z);
view(45, 30)
Try It
>> [X, Y] = meshgrid(-2:0.2:2);
Z = sin(X) .* cos(Y);
surf(X, Y, Z);
view(2)  % Top-down view
Try It
>> [X, Y] = meshgrid(-2:0.2:2);
Z = X.^2 - Y.^2;
mesh(X, Y, Z);
view(3)  % Default 3D view

See Also