I am trying to create a plot where the points would be added sequentially over multiple slides. But the added code produces a bunch of Undefined control sequence. errors.
Interestingly, when I use \x and \xi as the variable and the index variable respectively in the for loop, the code starts running and I get a huge 250+ page PDF! It's filled with empty plots except the very last page where the plot has all the points.
MWE:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.18}
\begin{document}
\begin{frame}{Frame name}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}
\foreach \point [count = \pointindex] in {-2, 5, -1}
{
\addplot [
only marks,
mark = *,
samples at = {\point},
visible on = <\pointindex->,
]
{x^2};
}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}

pgffor). – Saptam Dec 07 '22 at 07:49\xiis already defined (\mathchar"118) outside the loop and can be interpreted byvisbile on. Depending on the outside definition of the index variable macro you would get different result. Sometimes with, sometimes without error message. But always more or less an accident. – cabohah Dec 07 '22 at 08:15