I am struggling with following fairly simple looking problem of plotting a family of curves.
\documentclass[border=1mm]{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.8}
\pgfplotstableread{
1 1
2 4
3 9
4 16
5 25
}\dataQuad
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
legend pos=north west,
domain=0:5,
xlabel=${x}$,
ylabel=${y}$]
\foreach \y/\c in {2/black,3/green,4/red,5/brown}{%
\edef\temp{\noexpand\addplot[color=\c,line width=1pt] {x^\y};}
\temp
\addlegendentryexpanded{$y=x^\y$}
}
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[%
legend pos=north west,
domain=0:5,
cycle list name=color,
xlabel=${x}$,
ylabel=${y}$]
\addplot [smooth] table[x index=0, y index=1] {\dataQuad};
\legend{$y=x^2$}
\foreach \y in {3, 4, 5} {%
% \foreach \y/\c in {3/green,4/red,5/brown}{%
\addplot [smooth] table[x index=0, y expr=\thisrowno{0}^\y] {\dataQuad};
% \edef\temp{\noexpand\addplot [smooth] table[x index=0, y expr=\thisrowno{0}^\y] {\dataQuad};}
% \temp
\addlegendentryexpanded{$y=x^\y$}
}
\end{axis}
\end{tikzpicture}
\end{document}
I'd like to have the same result shown on the left when using a table with some math expressions. One problem is to handle the color management when uncomment the lines within second tikzpicture (by changing the foreach-loop). I can't get it to work. Seems to be a problem with expansion.
Any advice is much appreciated!
Thanks Paul

