I have found the following solution in stackexchange. It has been perfectly answered here by @Jake.
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
set layers=standard,
domain=0:10,
samples y=1,
view={40}{20},
hide axis,
unit vector ratio*=1 2 1,
xtick=\empty, ytick=\empty, ztick=\empty,
clip=false
]
\def\sumcurve{0}
\pgfplotsinvokeforeach{0.5,1.5,...,5.5}{
\draw [on layer=background, gray!20] (axis cs:0,#1,0) -- (axis cs:10,#1,0);
\addplot3 [on layer=main, blue!30, smooth, samples=101] (x,#1,{sin(#1*x*157))/(#1*2)});
\addplot3 [on layer=axis foreground, very thick, blue,ycomb, samples=2] (10.5,#1,{1/(#1*2)});
\xdef\sumcurve{\sumcurve + sin(#1*x*(157))/(#1*2)}
}
\addplot3 [red, samples=200] (x,0,{\sumcurve});
\draw [on layer=axis foreground] (axis cs:0,0,0) -- (axis cs:10,0,0);
\draw (axis cs:10.5,0.25,0) -- (axis cs:10.5,5.5,0);
\end{axis}
\end{tikzpicture}
\end{document}
I really liked the solution. I would be thankful if someone could explain the following features that have been utilized in the code so that I learn it and use it in the future.
\pgfplotsinvokeforeach: I read the manual and I still do not see its difference with\foreach. Why we are not usingforeach?\addplot3 (x,#1,{sin(#1*x*(157))/(#1*2)});: what is the difference betweenxand#1in this line code? What valuesxwill take?\def\sumcurve{0}: Does this one definesy=0curve?- I am a little bit confused about the layers in the code. Why do we need the layers?
unit vector ratio*=1 2 1: Is this used to simulate a nice three dimensional graph as shown here?

y=f_i(x), initialize aty=f_0(x)wheref_0(x)=0. Then\sumcurveis essentiallyy=f_0(x)+f_1(x)+f_2(x)+...+f_k(x). If you initialize\sumcurveto1, that's essentially the same thing as settingf_0(x)=1. – A.Ellett Jun 13 '14 at 00:35standard,main, andaxis foreground? – shashashamti2008 Jun 13 '14 at 01:57standardnames for configuring layers. If you look at the documentation inpgfplotsit explains under/pgfplots/layers/standardhow these layers are applied. – A.Ellett Jun 13 '14 at 02:21