My previous question made me take a look at pgfplots manual to understand the differences between \foreach and \pgfplotsinvokeforeach. However, the examples are not enough to comprehensively understand the differences and when to use each one.
Interestingly, I found the second variant of foreach (\pgfplotsforeachungrouped) whose examples are not verbosely explained nor enough.
Therefore, I would be grateful if there is an exemplary comparison between \foreach and its two variants to better understand them and wisely choose the appropriate one for my document.
\pgfplotsforeachungroupeddoes not wrap the loop body in groups and 2.\pgfplotsinvokeforeachexpands the loop "variable", whereas the other variant's do not. In case these statements do not make a lot of sense to you, you may want to look atTeX-programming-notes.pdfthat comes withpgfplotsandTeX by topic, which is included in the standard TeX installations. – Aug 27 '19 at 15:52