4

I was wondering how I could draw an arc in Tikz that has small gaps in it in a simple way, like this:

The arc

Here is working example:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
\draw (6,2.5) arc (0:180:4cm and 1cm);
\end{tikzpicture}
\end{figure}

\end{document}

The gaps need not be of different lengths.

Much appreciated,

Alex

Alex
  • 43
  • 5

3 Answers3

10

According to the pgfmanual section 15.3.2 Graphic Parameters: Dash Pattern, you have several possibilities:

\documentclass[tikz,border=10pt]{standalone}

\begin{document}
\begin{tikzpicture}[very thick]
\draw[dashed] (6,2.5) arc (0:180:4cm and 1cm);
\end{tikzpicture}

\begin{tikzpicture}[very thick]
\draw[loosely dashed] (6,2.5) arc (0:180:4cm and 1cm);
\end{tikzpicture}

\begin{tikzpicture}[very thick]
\draw[dash pattern=on 6mm off 7mm] (6,2.5) arc (0:180:4cm and 1cm);
\end{tikzpicture}
\end{document}

The result:

enter image description here

7

Try the dash pattern style on your path with on and off pairs:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw [dash pattern=on 1.5cm off 1cm on 1cm off 1cm on 1cm off .5cm on 1cm off .5cm]
    (6,2.5) arc (0:180:4cm and 1cm);
\end{tikzpicture}
\end{document}

result

salviati
  • 423
1

It seems that the dash pattern key option of tikz has been borrowed from MetaPost: the syntax is exactly the same. I couldn't let this pass without reacting, so for the sake of justice here is Salviati's example translated in tikz's original language :-)

beginfig(1);
    draw halfcircle xscaled (8cm) yscaled (2cm) 
        dashed dashpattern(on 1.5cm off 1cm on 1cm off 1cm on 1cm off .5cm on 1cm off .5cm);
endfig;
end.

enter image description here

Franck Pastor
  • 18,756