# Draw dots on specific points of a line

With the contribution of a kind user : it has been possible to reproduce this scheme :

Using this code :

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

\begin{document}
\begin{tikzpicture}
\draw[very thick](-6,0) -- (-3.84,0) -- ++ (1mm,2mm) -- ++ (2mm,-4mm) -- ++ (1mm,2mm)
-- ( 3.36,0) -- ++ (1mm,2mm) -- ++ (2mm,-4mm) -- ++ (1mm,2mm)
-- (6,0);
\foreach \x/\i in {-5/x_{{1}{2}}, -4/x_{\frac{3}{2}},-2/, -1/x_{i-\frac{3}{2}},
1/x_{i+\frac{3}{2}}, 2, 4/x_{N_x-\frac{1}{2}}, 5/x_{N_x+\frac{1}{2}}}
\draw(1.2*\x, 2mm) -- ++ (0,-4mm) node[below]{$\i$};
%
\foreach \x/\i [evaluate=\x as \xx using \x+1] in {-5/1, -2/i-1, -0.5/i, 1/i+1, 4/N_x}
\path (1.2*\x,0) -- node[above, font=\small] {$\i$} (1.2*\xx,0);

\end{tikzpicture}
\end{document}


Now I am trying to add dots on specific points like in the image below :

I tried to manipulate a little bit the line node[above,...] by writing :

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

\begin{document}
\begin{tikzpicture}
\draw[very thick](-6,0) -- (-3.84,0) -- ++ (1mm,2mm) -- ++ (2mm,-4mm) -- ++ (1mm,2mm)
-- ( 3.36,0) -- ++ (1mm,2mm) -- ++ (2mm,-4mm) -- ++ (1mm,2mm)
-- (6,0);
\foreach \x/\i in {-5/x_{{1}{2}}, -4/x_{\frac{3}{2}},-2/, -1/x_{i-\frac{3}{2}},
1/x_{i+\frac{3}{2}}, 2, 4/x_{N_x-\frac{1}{2}}, 5/x_{N_x+\frac{1}{2}}}
\draw(1.2*\x, 2mm) -- ++ (0,-4mm) node[below]{$\i$};
%
\foreach \x/\i [evaluate=\x as \xx using \x+1] in {-5/1, -2/i-1, -0.5/i, 1/i+1, 4/N_x}
\path (1.2*\x,0) -- node[circle,fill,above, font=\small] {$\i$} (1.2*\xx,0);

\end{tikzpicture}
\end{document}


And it ended up with this result ...

What is wrong with this try ?

Thank you very much for your help.

• Make two separate node, the one contain text should be above, the circle one should not be above. Commented May 15, 2022 at 11:24
• @user202729 I am trying to do so but I am surely writing it wrongly because it doesn't work : I have just added this line : \node[circle,fill,inner sep=1/8pt] {-5/1, -2/i-1, -0.5/i, 1/i+1, 4/N_x}; Commented May 15, 2022 at 12:10

Try replacing the line like this:

\path (1.2*\x,0) -- node[circle,fill,label=above:\small$\i$] {} (1.2*\xx,0);


\path (1.2*\x,0) -- node[circle,fill,above, font=\small] {$\i$} (1.2*\xx,0);