plot3

Plots lines and points in 3-D space.

Category: Graphics > 2-D and 3-D Plots

Syntax

plot3(X, Y, Z)

Draws a line through the points (X(k), Y(k), Z(k)). Matrices plot one line per column.

plot3(X, Y, Z, LineSpec)

Sets color, line style and marker.

plot3(___, Name, Value)

Sets line properties such as 'LineWidth'.

h = plot3(___)

Also returns the line handles.

Description

plot3 is the 3-D version of plot. It is the natural tool for trajectories, space curves and sets of 3-D points. The view can be rotated in the figure or set with view; grid on and axis equal often help the reading.

Input arguments

X, Y, Z
Coordinates of equal size.
LineSpec
String such as 'r--o' for color, style and marker.

Output arguments

h
Handles of the lines, with XData, YData and ZData properties.

Example

Helix

t = linspace(0, 6*pi, 200);
plot3(cos(t), sin(t), t, 'LineWidth', 2)
grid on

In the app, the figure is drawn below the code.

See also

plot scatter3 fplot3 view comet3