Join two function-based curves in Tikz

I have the following:

\begin{tikzpicture}[line cap=round,line join=round]
\draw[dashed,domain=0:9,samples=20] plot (\x,{1/(\x+.5)+3});
\draw[dashed,domain=0:9,samples=20] plot (\x,-{1/(\x+.5)+2});
\end{tikzpicture}


Is it possible to properly join the two ends of each curve to obtain a nice final dashed line surrounding the domain defined by the two curves?

Is this what you mean?

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
\draw[dashed,domain=0:9,samples=20] plot (\x,{1/(\x+.5)+3}) --
plot [domain=9:0] (\x,-{1/(\x+.5)+2}) --cycle;
\end{tikzpicture}
\end{document}


Switching the order of the domain in the second plot lets the right side connect to the right side (I actually have no idea if this is intended behavior, or if I'm exploiting a bug here, but I've found it handy before), and --cycle makes it connect the end to the beginning.

• yes! I tried to invert the domain for the second plot but it did not work. I am not sure why. – pluton Apr 23 '13 at 4:01