I'm creating a simple number line using the example Labeled Number Line. Where I'm getting stuck is that I want the x axis to start at 120 and go to 280 and only display intervals of 20 (120,140,160...260,280).

If I can do it without using pgfplots and just use TikZ that would be helpful (I'm only using BasicTex on Mac and get an error when I try to \usepackage{pgfplots}).

This is my code:


\draw[thin] (0.5,0) -- (10.5,0);
\path [draw=black, fill=black] (1,0) circle (2pt);
\path [draw=black, fill=black] (10,0) circle (2pt);
\foreach \x  in {1,...,10}
\draw[xshift=\x cm] (0pt,2pt) -- (0pt,-2pt) node[below,fill=white] {120};
\draw[ultra thick] (1,0) -- (10,0);

  • Update your basictex to include pgfplots it is worth it. In general only install BasicTeX if really have no space left for a full installation.
    – daleif
    Oct 5, 2016 at 9:07

1 Answer 1


You just need a small adjustment to your \foreach loop, and all 10 to 9, otherwise the numberline will have room to go to 300, instead of 280.

enter image description here


\draw[thin] (0.5,0) -- (9.5,0);
\filldraw (1,0) circle[radius=2pt]
          (9,0) circle[radius=2pt];
\foreach [count=\i] \x  in {120,140,...,280}
   \draw (\i,2pt) -- (\i,-2pt) node[below,fill=white] {\x};

\draw[ultra thick] (1,0) -- (9,0);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .