I have some points defined via
\coordinate (A1) at (-4,0);
\coordinate (B1) at (-2,1);
\coordinate (C1) at (0,0);
...
And I want to place a little dash at their location. I tied two approaches, but both throw me a bunch of errors
\foreach \p in {A1,B1,C1,A2,B2,C2,A3,B3,C3}{
\draw[thick] ([yshift=-2pt]\p) -- ([yshift=2pt]\p);
}
\foreach \p in {A1,B1,C1,A2,B2,C2,A3,B3,C3}{
\draw[thick] ($(\p)+(0,1)$) -- ($(\p)+(0,-1)$);
}
Here is MWE if you want to reproduce the error
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
axis lines = center,
ymin=-1,
ymax=2,
xmin=-6,
xmax=10,
width=9cm,
clip=false
]
\coordinate (A1) at (-4,0);
\coordinate (B1) at (-2,1);
\coordinate (C1) at (0,0);
\foreach \p in {A1,B1,C1}{
\draw[thick] ($(\p)+(0,1)$) -- ($(\p)+(0,-1)$);
}
\end{axis}
\end{tikzpicture}
\end{document}


tikzbutpgfplots. At he later you cant use\foreachloops on your way. I wonder, why you usepgfplots, wha˙t is purpose of this small lines, etc. They can be replaced wit some mark and defined something like `\addtplot [coordinates only, mark=|] coordinates {(<coordinate 1>) (<coordinate 2>) ... (ycoordinate n>)} – Zarko Jun 22 '21 at 11:53tikzpackage as far as I know,pgfplotsincludes it, so there should be not any issues with\foreach. – antshar Jun 22 '21 at 11:58