13

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?

pluton
  • 16,421

1 Answers1

15

Is this what you mean?

connecting the dashes of two plots

\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.

kmacinnis
  • 1,655