# Plotting several 2D plots on one 3D graph [duplicate]

I know that there are some similar questions but I don't find the solution to my problem.

I have made several 2D spectrum plots from data of txt files (colunm1 vs column2. Each one showing a plot from select files of data from a series of times that I calculated how Table[expression],{i,n}] where n is the number of files. So the first plot is time t0, the second is time t1 and so on.

I wanted to plot all these plots in one 3D-plot with the new z-axis being the time. So the first 2D spectrum plot would be on 0 of the z-axis, the second would be on t1 of the z-axis and so on. Basically I want to combine the files of data of the planes into a variable on the z-axis so that I can plot my data in 3D.

I want to do how this example:

http://cloud.originlab.com/www/products/images/Waterfall_3D_sm1.png

This is my code:

Clear["Global*"]
SetDirectory["DIR"];
inttime = 4;
totalfiles = Length[FileNames["*.txt"]];

files = Table[FileNames["*.txt"][[i]], {i, totalfiles}];
m = Import[#, "Table"] & /@ files;
n = Length[m];

numfile =
ToExpression[
Table[Extract[StringSplit[files[[i]], {"."}], 1], {i, n}]]

tmin = (numfile - 1)*inttime/60.

ListLinePlot[m, GridLines -> Automatic,
FrameTicks -> {{Automatic, None}, {Automatic, None}},
PlotRange -> {{400, 700}, {0, All}}, Frame -> True,
LabelStyle -> Directive[Black, 10, FontFamily -> "Arial"]]


And these the files:

https://www.cubbyusercontent.com/pl/t/_5d53da1902934a319fb406b6941e579e

I want plotting m[[i]] with z-axis being the tmin.

I've tried with the code of your answers but I don't get to work it.

• Perhaps you can put your data in a format that can be fed to ListSliceContourPlot3D Jul 20, 2016 at 13:32
• I've tried it but I don't understand good. My files have two columns that I plloting in 2D. Each plot 2D corresponding one time: t0, t1, t2, etc.... I dont know how to put this time in the z-axis of the new 3D plot.
– Manu
Jul 20, 2016 at 13:51
• I think this plot from the answer of "Import and Plot Git Commit History" does what you want. You can find the code in GitHub. Jul 20, 2016 at 13:53
• @Manu - the figure you linked looks a lot like these Jul 20, 2016 at 13:55
• @JasonB I like those plots and they seem very relevant for this discussion. Jul 20, 2016 at 14:00

Do[data[i] = Table[{x, i Sin[i x]}, {x, 0, Pi, Pi/50}], {i, 10}]


This is going to be your imported files

layer[data_, n_, col_] := {Opacity[0.5], col, EdgeForm[Black],
Polygon[data /. {x_, z_} :> {x, n, z}]}

Graphics3D[Table[layer[data[i], i, Hue[i/10]], {i, 10}],
PlotRange -> {All, {0, 11}, All}, BoxRatios -> {1, 1, .5},
Axes -> True, FaceGrids -> {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}},
PlotLabel -> "Some Label", AxesLabel -> {"x", "n", "f(x)"}, Boxed -> True] You might also want to look at

Mathematica: 3D plot based on combined 2D graphs

If all your data file have same number of data then you can try something like this

ndata = Length[data]; nset = 10;

bigdata = Flatten[Join[Table[data[n] /. {x_, y_} :> {x, n, y}, {n, nset}]], 1];
row = Partition[bigdata, ndata];
col = bigdata[[# ;; ;; ndata]] & /@ Range[ndata];
Graphics3D[{Blue, Map[Line, row], Red,  Map[Line, col]}, PlotRange -> {All, {0, 11}, All},
BoxRatios -> {1, 1, .5}, Axes -> True, FaceGrids -> {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}},
PlotLabel -> "Some Label", AxesLabel -> {"x", "n", "f(x)"}, Boxed -> True] • I have a possible solution. Finally, I've created mtime variable which I add third column of data tmin and plotting with ListPlot3D. This is the final code: mtime = Table[ArrayFlatten@{{m[[i]], tmin[[i]]}}, {i, n}]; ListPointPlot3D[mtime, PlotRange -> All, LabelStyle -> Directive[Black, 10, FontFamily -> "Arial"], ViewPoint -> {-2.39, 0.13, 2.38}, ViewVertical -> {-0.40, 0.8, 1}]
– Manu
Jul 21, 2016 at 13:13
• Now, I don´t know how join the points. ListLinePlot3D not is support in Mathematica.
– Manu
Jul 21, 2016 at 13:47
• Did you look at J.M.'s link on top of your question? Jul 21, 2016 at 15:14