I want to draw two dashed red line like the one in the second figure.
\documentclass{minimal}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\draw[->] (-0.2,0) -- (4.5,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,2.5) node[above] {$f(x)$};
\draw[dash pattern=on 0pt off 2\pgflinewidth,line cap=round,line width=0.5mm,color=blue,domain=0:4,samples=100] plot (\x,{1+ sin(10*\x r)*e^(-\x)}) ;
\end{tikzpicture}
\end{document}



minimal, butarticle. See https://tex.stackexchange.com/questions/42114/why-should-the-minimal-class-be-avoided – Torbjørn T. Apr 09 '18 at 12:27