Following the issue Color Management with a Family of Curves I couldn't find a proper way of creating the associated table for a family of curves.
I tried to create new columns with respect to the parameter \y
(exponent), but without success using \foreach
or \pgfplotsinvokeforeach
(see comment lines).
Here is the code:
\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{minipage}[c]{0.75\textwidth}
\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/\c in {3/green,4/red,5/brown}{%
\edef\temp{\noexpand\addplot [color=\c,smooth] table[x index=0, y expr=\noexpand\thisrowno{0}^\y] {\noexpand\dataQuad};}
\temp
\addlegendentryexpanded{$y=x^\y$}
}
\end{axis}
\end{tikzpicture}
\end{minipage}
%
\begin{minipage}[c]{0.75\textwidth}
\pgfplotstablecreatecol[
create col/assign/.code={%
\foreach \y in {3,4,5} {%
% \pgfplotsinvokeforeach{3,4,5} {%
\pgfmathparse{\thisrow{1}*\y}
% \thisrow{1}*#1
}
\pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult
}
]{exp}\dataQuad
\pgfplotstabletypeset[columns={[index]0,[index]1,exp}]\dataQuad
\end{minipage}
\end{document}
What goes wrong here? Additionally, a header for each column with reference to each list entry from '{3,4,5}' would be great.
Thanks again, Paul
OK, the error '! Package PGF Math Error: Sorry, an internal routine of the floating point unit' from above occurs when defining a list with \newcommand{\param}{2,3,4,5}
, see following MWE:
\documentclass[border=1mm]{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.8}
\pgfplotstableread{
1
2
3
4
5
}\dataQuad
\newcommand{\param}{2,3,4,5}
\pgfplotsforeachungrouped \y in \param {%
\pgfplotstablecreatecol[
create col/expr={\thisrow{0}^\y}
]{\y}\dataQuad
}
\begin{document}
\begin{minipage}[c]{0.75\textwidth}
\begin{tikzpicture}
\begin{axis}[%
legend pos=north west,
domain=0:5,
cycle list={green, red, black, purple, orange},
xlabel=${x}$,
ylabel=${y}$]
\pgfplotsinvokeforeach{2,...,5}{
\addplot +[smooth] table [x index=0, y=#1] \dataQuad;
}
\end{axis}
\end{tikzpicture}
\end{minipage}
\begin{minipage}[c]{0.75\textwidth}
\pgfplotstabletypeset\dataQuad
\end{minipage}
\end{document}
Do I have to use another approach for predefine a list?
Thanks, Paul