# Plotting several 2d functions in a 3d graph

I am trying to reproduce a similar figure to the following one. My first guess was to use pgfplots but I didn't find any example that I could use as a starting point. At the moment I am unsure if pgfplots is actually the right package or I should rely on something else e.g. TikZ.

Since I don't really know where to start, I would appreciate any piece of code that points me in the right direction. EDIT

Here is some dummy data for the plots.

plot1   plot2   plot3   plot4
0       0       0       0
3.466   2.058   0       0
4.262   2.976   0.001   0
3.822   3.168   0.006   0.008
2.953   2.936   0.019   0.063
2.065   2.492   0.046   0.265
1.332   1.977   0.092   0.734
0.797   1.478   0.164   1.508
0.443   1.045   0.268   2.44
0.228   0.698   0.412   3.219
0.107   0.438   0.598   3.524
0.046   0.256   0.831   3.219
0.017   0.138   1.109   2.44
0.006   0.067   1.429   1.508
0.002   0.029   1.78    0.734
0       0.01    2.141   0.265
0       0.003   2.479   0.063
0       0.001   2.736   0.008
0       0       2.808   0
0       0       2.465   0
0       0       0       0

• pgfplots is certainly an appropriate choice for this. Note that pgfplots is based off the pgf/tikz package. For your particular image, you'll be using \addplot3...., and to get the curves in the x-y plane you could use \addplot3 but with z=0. If you could provide more information (such as formulas, or data points, or what you've tried so far), folks might be able to help with more detail :) – cmhughes Apr 30 '12 at 8:29

Tabulated data can be plotted in different planes quite easily by using \addplot3 table [y expr=<value>, z=<name of column in table>] {<file name or table macro>};.

You can use \pgfplotsinvokeforeach{<list expression>}{...} to repeat the plot commands. Here's an example of how to plot your dummy data: \documentclass{article}
\usepackage{pgfplots,pgfplotstable}
\begin{document}
\begin{tikzpicture}

plot1   plot2   plot3   plot4
0       0       0       0
3.466   2.058   0       0
4.262   2.976   0.001   0
3.822   3.168   0.006   0.008
2.953   2.936   0.019   0.063
2.065   2.492   0.046   0.265
1.332   1.977   0.092   0.734
0.797   1.478   0.164   1.508
0.443   1.045   0.268   2.44
0.228   0.698   0.412   3.219
0.107   0.438   0.598   3.524
0.046   0.256   0.831   3.219
0.017   0.138   1.109   2.44
0.006   0.067   1.429   1.508
0.002   0.029   1.78    0.734
0       0.01    2.141   0.265
0       0.003   2.479   0.063
0       0.001   2.736   0.008
0       0       2.808   0
0       0       2.465   0
0       0       0       0
}\dummydata

\begin{axis}[
samples=30,
domain=-4:4,
samples y=0, ytick={1,...,4},
zmin=0,
area plot/.style={
fill opacity=0.75,
draw=orange!80!black,thick,
fill=orange,
mark=none,
}
]
\pgfplotsinvokeforeach{4,3,...,1}{
\addplot3 [area plot] table [x expr=\coordindex, y expr=#1, z=plot#1] {\dummydata};
}
\end{axis}
\end{tikzpicture}

\end{document}


And here's an example of plotting a couple of functions: \documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[
declare function={
normal(\m,\s)=1/(2*\s*sqrt(pi))*exp(-(x-\m)^2/(2*\s^2));
}
]
\begin{axis}[
samples=30,
domain=-4:4,
samples y=0, ytick=data,
zmin=0,
area plot/.style={
fill opacity=0.75,
draw=none,
fill=orange,
mark=none,
smooth
}
]
0 4 0
-0.75 3 0
-1.9 2 0
-1.2 1 0
};