I desperately need some help with the following: In this MWE I would like to draw a circle (ideally: a vertical line) at an x value coming from a foreach command.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=10cm,
height=10cm,
grid=major,
xlabel=$x$,
ylabel=$f(x)$,
xmin=-4,
xmax=3,
]
\addplot[domain=0:1] (x,x^2);
\foreach \xj in {
{(-3,0)},
{(-2,1)}
} {
\draw \xj circle[radius=1em];
%\draw \xj -- (0,0);
}
\foreach \xj in {-5,-4,...,5} {
%\draw (-2.5,0.5) circle[radius=1em];
\draw (\xj,0.5) circle[radius=1em];
%\draw (\xj,0.5) -- (\xj, 1);
}
\end{axis}
\end{tikzpicture}
\end{document}
The addplot command is used to being able to adjust the axis. For some reason, that does not work unless there is this addplot present. But that is not the issue. The issue is this:
The first foreach command gives me errors, but compiles nonetheless. However, the circle that is drawn is at the left border of the plot domain. Theres something wrong here...
The second foreach command throws so many errors that the file doesn't compile anymore. I have no idea why this does not work, but it is because the \x is in the definition of the draw command. If changing the \x to lets say -2.5, the file compiles fine.
Any ideas why this does not work like I hoped it would, and any ideas on how to fix this issue?