Documentation Center

  • Trial Software
  • Product Updates

Line Plots of 3-D Data

Basic 3-D Plotting: The plot3 function

The 3-D analog of the plot function is plot3. If x, y, and z are three vectors of the same length,


generates a line in 3-D through the points whose coordinates are the elements of x, y, and z and then produces a 2-D projection of that line on the screen. For example, these statements produce a helix:

t = 0:pi/50:10*pi;
axis square; grid on

Plotting Matrix Data

If the arguments to plot3 are matrices of the same size, lines obtained from the columns of X, Y, and Z are plotted. For example:

[X,Y] = meshgrid([-2:0.1:2]);
grid on

Notice how line colors cycle, based on the axes ColorOrder property.

Was this topic helpful?