1
$\begingroup$

This question already has an answer here:

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.

$\endgroup$

marked as duplicate by J. M. will be back soon Jul 20 '16 at 17:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Perhaps you can put your data in a format that can be fed to ListSliceContourPlot3D $\endgroup$ – Jason B. Jul 20 '16 at 13:32
  • $\begingroup$ 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 don`t know how to put this time in the z-axis of the new 3D plot. $\endgroup$ – Manu Jul 20 '16 at 13:51
  • $\begingroup$ 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. $\endgroup$ – Anton Antonov Jul 20 '16 at 13:53
  • $\begingroup$ @Manu - the figure you linked looks a lot like these $\endgroup$ – Jason B. Jul 20 '16 at 13:55
  • $\begingroup$ @JasonB I like those plots and they seem very relevant for this discussion. $\endgroup$ – Anton Antonov Jul 20 '16 at 14:00
3
$\begingroup$

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.