I am trying to plot several column pairs using the \foreach loop command with pgfplotstable in the following way.
\documentclass[tikz]{standalone}
\usepackage{pgfplots,pgfplotstable}
\begin{document}
\begin{tikzpicture}
\def \x {data.txt}
\begin{axis}
[
xlabel={x},
ylabel={y},
]
\foreach \i/\j in {0/1,2/3,4/5,6/7,8/9,10/11}{
\edef\temp{\noexpand\addplot[smooth,color=blue,no marks] table[x index=\i,y index=\j] {\x};
}
\temp
}
\end{axis}
\end{tikzpicture}
\end{document}
Is there a way to automate list creation over two variables as in something like
\foreach \i/\j in {0/1,2/3,...,10/11}
which does not seem to work?
\pgfplotsinvokeforeach, see the end of section 4.6.3 of the manual... – Apr 09 '18 at 01:54\foreach\x[count=\xi from 0] in{1,...,11}or useevaluateif you have complicated expression\ – percusse Apr 09 '18 at 08:41evaluatereturns a number that is a floating point number and cannot be passed as a row/column index for plotting purposes. – scorpionwars Apr 11 '18 at 01:41int(<calculation>)gives you an integer. – Torbjørn T. Apr 11 '18 at 14:55