Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a simple way to draw a line like with \draw[dotted] (0,0) -- (1,0); but with larger (radius about 1mm) and more distant (about 4mm) dots?

I've looked in the TikZ & PGF manual, section "15.3.2 Graphic Parameters: Dash Pattern" but found nothing useful.

My workaround is using a \foreach and drawing circle nodes.

share|improve this question

2 Answers 2

up vote 21 down vote accepted

You can use a decoration:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[decoration={markings,
  mark=between positions 0 and 1 step 6pt
  with { \draw [fill] (0,0) circle [radius=2pt];}}]
\path[postaction={decorate}] (0,0) to (4,0);
\end{tikzpicture}

\end{document}

enter image description here

Or using decorations.shapes:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.shapes}

\begin{document}

\tikzset{decorate sep/.style 2 args=
{decorate,decoration={shape backgrounds,shape=circle,shape size=#1,shape sep=#2}}}

\begin{tikzpicture}
\draw[decorate sep={2mm}{4mm},fill] (0,0) -- (4,0);
\draw[decorate sep={2mm}{6mm},fill] (0,1) -- (4,1);
\draw[decorate sep={1mm}{4mm},fill] (0,2) -- (4,2);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Thanks for your help! I like your second solution more, it looks cleaner… –  siegi Apr 22 '12 at 9:10

It's possible with simple options. Logically with dotted, you get only squares or rectangles.

For example :

\documentclass[11pt]{scrartcl}
\usepackage{tikz}    
\begin{document}
\begin{tikzpicture}
\tikzstyle{dotted}= [dash pattern=on \pgflinewidth off 4mm]  
\draw[dotted,line width = 2mm] (0,0) -- (5,0);
\end{tikzpicture}    
\end{document}

enter image description here

A strange idea is to use line cap=round to get circles instead squares. A pattern is a rectangle but with line cap=round you get a ice rink and if you reduce the width enough, you get circles. The method is funny.

update I added a style

\documentclass[11pt]{scrartcl}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[circle dotted/.style={dash pattern=on .05mm off 8mm,
                                         line cap=round}]
  \draw[line width = 2mm,circle dotted] (0,0) -- (10,0);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
This is indeed a funny solution, thanks :-) –  siegi Apr 22 '12 at 9:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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