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}
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}