4
$\begingroup$

The curves are composed by several 2*n nested lists. I want these curves be placed in a 3d way, like the xy plane is for the data, different curves are located in several parallel xy planes with different z values. The graph is similiar to this one. Is there any build in function can draw graphs like this? Plus, how to deal with errorbars?

Thanks a lot for helping. graph example I tried with this simplified data, but I can only got the 2d graph using ErrorListPlot.

Needs["ErrorBarPlots`"]
data = Table[Table[{{x, a^2 Sum[-Sin[n x]^2 + 1, {n, 1, 10}]},ErrorBar[0, x]}, {x, 2.5, 3.5, 0.01}], {a, 1, 3, 0.5}];
ErrorListPlot[data, PlotRange -> All, AspectRatio ->1/GoldenRatio]

bad example

$\endgroup$
1
  • 4
    $\begingroup$ Are you sure that adding error bars to such a plot is a good idea? I feel that they will make this plot completely unreadable and useless... $\endgroup$ Nov 18, 2014 at 5:41

1 Answer 1

1
$\begingroup$

I would say you can do something like this to produce a colored plot:

n = 20; m = 12;
DATA[1] = Table[{0, Random[], Random[]}, {j, 1, n}];
For[i = 2, i <= m, i++,
  DATA[i] = 
    DATA[i - 1] + 
     Table[{1/n, RandomReal[{-1, 1}]/20, RandomReal[{-1, 1}]/20}, {j, 
       1, n}];
  ];

Graphics3D[
 Table[
  {
   ColorData["Rainbow"][i/m],
   Line[Sort[DATA[i]]]
   },
  {i, 1, m}
  ],
 Axes -> True,
 PlotRange -> {{0, 1}, {0, 1}, {0, 1}}
 ]

However, that doesn't account for the error bars. The ErrorBarPlots package doesn't seem to have any Graphics3D constructions, which means you might not be able to find an automatic command to do this. I don't see a way to do that that doesn't require us to really just draw all of the error bars by hand, just giving something as complicated (but more or less the same) as what I give above.

$\endgroup$
3
  • $\begingroup$ I know this isn't the crux of the question, but wouldn't the data be more simply constructed using FoldList rather than a For loop? i.e. DATA=FoldList[#1+#2&, Table[{0, Random[], Random[]}, {n}], Table[{1/n, RandomReal[{-1, 1}]/20, RandomReal[{-1, 1}]/20}, {m-1},{n}]]. At the very least, the Table construct doesn't require an explicit j iterator. $\endgroup$
    – Verbeia
    Dec 18, 2014 at 6:35
  • $\begingroup$ NSure, there are plenty of ways to write this up and get the same output. I'm not a code-golf kind of guy, I tend to write code that isn't optimal and for this type of application I don't see the difference so I wouldn't go back and optimize it. $\endgroup$ Dec 21, 2014 at 3:27
  • 1
    $\begingroup$ No idea how that "N" got in there... let's say NSure is the numerical version of Sure... $\endgroup$ Dec 21, 2014 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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