1

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.

Please, any indication?

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.

Manu
  • 119
  • 1
  • 9

1 Answers1

3

Adding some decoration on JasonB's answer

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]

enter image description here

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[1]]; 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]

enter image description here

Sumit
  • 15,912
  • 2
  • 31
  • 73
  • 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 '16 at 13:13
  • Now, I don´t know how join the points. ListLinePlot3D not is support in Mathematica. – Manu Jul 21 '16 at 13:47
  • 1
    Did you look at J.M.'s link on top of your question? – Sumit Jul 21 '16 at 15:14