8
$\begingroup$

I want to plot several 2D curves (Sin[x] at y=0, Cos[x] at y=1) in a 3D plot, what function should i use?

f[x_, y_] := Piecewise[{{0, y < 0 || y > 0}, {Sin[x], y == 0}}]
g[x_, y_] := Piecewise[{{0, y < 1 || y > 1}, {Cos[x], y == 1}}]
Plot3D[{f[x, y], g[x, y]}, {x, 0, 10}, {y, 0, 10}]

doesn't work. Any ideas?

$\endgroup$
4
  • 1
    $\begingroup$ Have you seen ParametricPlot3D[]? $\endgroup$ Commented May 11, 2013 at 6:37
  • $\begingroup$ In fact a more general question behind this is how to make a waterfall plot. I found some discussions here $\endgroup$
    – xzczd
    Commented May 11, 2013 at 6:46
  • $\begingroup$ To avoid analytic geometry, check out Graphics3D: Tube. Sometimes it is more useful. $\endgroup$
    – Kuba
    Commented May 11, 2013 at 7:24
  • $\begingroup$ Plot3D draws a surface, you need ParametricPlot3D with one parameter (for a curve) or points for Line and Graphics3D. $\endgroup$
    – BoLe
    Commented May 11, 2013 at 14:03

1 Answer 1

19
$\begingroup$
ParametricPlot3D[{{Sin[u], 0, u}, {Cos[u], 1, u}}, {u, 0, 20}, 
 BoxRatios -> 1, PlotRange -> {{-2, 2}, {-.5, 2}, {0, 20}}]

enter image description here

=== update - general thoughts ===

I've seen the comments to this question and a few other approaches to the waterfall (or wire) plot are given in this question: Plotting several functions. Also I cannot not mention one of my favorite Mathematica blogs - Archery with this post on the story of discovery of 1st pulsar and an its infamous graphics - code is given in the post:

enter image description here

$\endgroup$

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