Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

Plot

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
share|improve this question
1  
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
add comment

1 Answer

up vote 39 down vote accepted

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}

\pgfplotstableread{
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
    }
]
\addplot3 [black, thick] table {
0 4 0
-0.75 3 0
-1.9 2 0
-1.2 1 0
};
\addplot3 [area plot] (x,4,{normal(0,1)});
\addplot3 [area plot] (x,3,{normal(-0.75,1)}) -- (axis cs:-4,3,0);
\addplot3 [area plot] (x,2,{normal(-1.9,0.7)}) -- (axis cs:-4,2,0);
\addplot3 [area plot] (x,1,{normal(-1.2,1.2)}) -- (axis cs:-4,1,0);

\end{axis}
\end{tikzpicture}

\end{document}
share|improve this answer
1  
Nice! I think at the back wall (!?) you can sum the columns and plot that too for the original cumulative effect. –  percusse Apr 30 '12 at 10:49
    
i ll be thankful to you if u give me the codes fr matlab fr the same process of arranging 2d grapphs in 3d plot –  user17922 Aug 23 '12 at 9:17
    
@upendran Welcome to TeX.sx! Your question won't be seen by many people here, so it would be best to repost it as a fresh question. Follow-up questions like this are more than welcome! Please use the "Ask Question" link for your new question; there you can link to this question to provide the background. –  Joseph Wright Aug 23 '12 at 12:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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