12

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?

14

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.

  • 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
  • @kmacinnis, nice answer. Could you please help me with this related issue? – juliohm Oct 24 '13 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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