MATLAB: How to plot multiple 2D time series detached in a 3D plot in MATLAB 7.14 (R2012a)

2d3dcombinedetachedMATLABmultipleoffsetplot

I want to plot multiple 2D time series in a detached layout in a 3D plot. I know there's a 'detached' style when creating bar plots with BAR3 however I want to achieve a similar layout with a normal plot. PLOT3 does not provide a 'style' option.

Best Answer

In order to plot 2D timeseries in a detached style in a 3D plot you can plot in the x-z-plane setting y as a vector containing constant values. So the resulting x-z curves will be detached in y-direction:
n=5;
% matrix containing the time information 1:5 for each column
x=repmat((1:n)',1,n)
% matrix containing the constant y offset per column
y=x'
% data matrix containing the data series as columns
z=magic(n)
% plot the data
plot3(x,y,z,'linewidth',2,'marker','o')
grid on
xlabel('time')
ylabel('data series')
Related Question