4

I need to draw this style of line

enter image description here

For this I use method which consist of using two styles of dashed line on the same path

\documentclass[border=3mm]{standalone}
\usepackage{tikz}

\tikzset{dashed with dot/.style={line cap=round,line width=3pt,dash pattern=on 0pt off 35pt},
my dash/.style={thick,dash pattern=on 20pt off 15pt}}


\begin{document}

\begin{tikzpicture}

\draw[my dash] (0,0) to[bend right] +(4.8,2.3); 
\draw[dashed with dot] (0,0) to[bend right] +(4.8,2.3);

\end{tikzpicture}

\end{document}

My question is how can improve my code simply with one command without repeating the draw command second time. I thought, this is possible if I can customize the dashed line style to obtain the desired style.

4

Se, if the following solution is what you looking for:

\documentclass[tikz, border=3mm]{standalone}

\tikzset{
my dash/.style={thick,dash pattern=on 20pt off 15pt,
                postaction={draw, line cap=round, line width=3pt,
                            dash pattern=on 0.1pt off 34.9pt},
                }
         }% end of tikzset

\begin{document}
    \begin{tikzpicture}
\draw[my dash] (0,0) to[bend right] +(4.8,2.3);
    \end{tikzpicture}
\end{document}

enter image description here

  • Thanks Zarko, postaction is what I need. – Salim Bou Feb 4 '17 at 17:38
  • Interestingly, if I for postaction I have used your original pattern, than the first line was without of dot. So I slightly change pattern and consequently the dots aren't perfect circle even more but circle with very small difference between axes (~0.1pt). Till to now I didn't figured out, why this happen. Anyway, differences are almost invisible, I thought. – Zarko Feb 4 '17 at 17:45

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.