I have a table with 8 columns, and I want to generate 4 plots (1 vs 0, 3 vs 2, 5 vs 4, and 7 vs 6). I was going to use foreach to generate the plots using
\begin{tikzpicture}
\begin{axis}
\foreach \x in {0,...,3} {
\addplot table[x index = \x * 2, y index = \x * 2 + 1]\table
}
\end{axis}
\end{tikzpicture}
where \table is a stored table.
But I don't seem to permitted to do arithmetic on the indices. Is there a way to do this ?
Update: not-quite-m WE:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{tikzpicture}
\pgfplotstableread{
-1.5875 -1.5324 -1.4773 -1.4222 -1.3671 -1.312 -1.2569 -1.2018
-1.5875 -1.5324 -1.4773 -1.4222 -1.3671 -1.312 -1.2569 -1.2018
0.013166 0.013156 0.013147 0.013141 0.013137 0.013135 0.013135 0.013139
0.013156 0.013146 0.013138 0.013132 0.013128 0.013127 0.013128 0.013131
}\loadedtable
\pgfplotstabletranspose[colnames from=,input colnames to=r]\transtable\loadedtable
\begin{axis}
\foreach \x in {0,...,1} {
\pgfmathtruncatemacro{\Xcol}{\x * 2}
\pgfmathtruncatemacro{\Ycol}{1 + \x * 2}
\addplot[mark=,color=blue] table[x index =\Xcol,y index =\Ycol]\transtable;
}
\end{axis}
\end{tikzpicture}
\end{document}

\pgfmathtruncatemacro{\XColumn}{\x*2}, and then usex index = XColumn. Similarly for they index. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the\documentclassand the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Dec 5 '12 at 2:58