MATLAB Answers


3D line plot

Asked by Xiu
on 28 Oct 2011

How to generate a 3D line plot? I know how to generate 3D surface plot using mesh,surf,etc. But instead of surface, i want line plot. for example, I have a set of data, i want to plot the data against time stamp and variables. I tried using plot3, but this function require the inputs to have same dimension. Can anyone help me with this, please?


Log in to comment.


1 Answer

Answer by Fangjun Jiang on 28 Oct 2011
 Accepted Answer

If you want to plot 3D lines, you need to have 3D data, whether the data is the typical x,y,z coordinates or one of the dimension is time.

line() can support (x,y,z) pairs.


on 28 Oct 2011

Say i have a data set with dimension of m by n. I want to plot the data on z axis, a vector of m on y axis and a vector of n on x axis.
from my understanding of function line(), the dimension of the inputs must be the same, which in my case, I have two vectors with different size and a matrix.

Maybe you need to use meshgrid() to create the vector for m and n
plot3(x,y,d);grid on;

on 28 Oct 2011

thank you so much. That is very helpful.

Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!