# Create a 3D stack of 2D line plots [duplicate]

A simple concept but I've not been able to solve it. I'm trying to create a stack of 2D plots in 3D space using Mathematica 9. This is not a parametric plot, but I'm creating it from an array of vectors (imported .csv file). The ListPlot3D function creates a filled mesh but what I want is this type of plot (created by HYRY in StackExchange: 'Matplotlib plot pulse propagation in 3d'):

I have tried changing the function options for ListPlot3D and was going to create an array of plot images (.jpg) to stack in 3D, each one having an alpha value - but that would not be good. Any help is appreciated.

Thank you,

Marc

– Kuba
Commented Jun 15, 2017 at 12:40

Here's one way, using Graphics3D and starting from a list of $x,y,z$ values for datapoints.

Mock data:

data = Flatten[Table[
{x, y, PDF[MultinormalDistribution[{0, 0}, {{0.2, 0.1}, {0.1, 0.4}}],{x, y}]},
{x, -2, 2, 0.01}, {y, -2, 2, 0.25}],1];


Group by y-value:

gb = GatherBy[data, #[[2]] &];


Some fancy styling (not necessary):

cLines = Transpose[{
ColorData["BlueGreenYellow"] /@ Rescale[Range[Length[gb]]],
Line /@ gb
}];


And plot (with some options to help the plot styling):

Graphics3D[
{Thick, cLines},
Axes -> True, Boxed -> False, BoxRatios -> {1, 1, 1},
FaceGrids -> {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}},
AxesLabel -> {"x", "y", "z"}, PlotRangePadding -> None]


• Thank you - this is great! I did not think about reformatting the data first. Commented Jun 15, 2017 at 13:19

You can also use ParametricPlot3D:

f[x_, y_] := Exp[-x^2 - y^2/(4 + x^2/4) + x y];
ParametricPlot3D[Table[{x, y, f[x, y]}, {y, -5, 5}], {x, -5, 5},
PlotRange -> All]


]

• Thanks Yohbs - I'm trying to do this for an array of vectors (e.g. imported .csv) rather than for a list a parametric values. Commented Jun 15, 2017 at 13:46
• No problem. In retrospect I still think the easiest solution is simply using ListPlot3D with the Mesh option as detailed in the question @Kuba referred to. Commented Jun 15, 2017 at 13:49