Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This type of error (! Package PGF Math Error: Sorry, an internal routine of the floating point unit got an ill-formatted floating point number ...) arises when trying to use a predefined list for the \pgfplotsforeachungrouped-loop. This problem is related to parameter studies where all significant parameters are put into a list, e.g. Create Table for a Family of Curves.

Following MWE shows the compiling error:

\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}

A similar problem was discussed here Using Macro Defined Lists in TikZ/PGFplots, but don't bring any solution for this particular problem.

So far I use \newcommand{\paramA}{2},\newcommand{\paramB}{3}, and so forth and looping via \pgfplotsforeachungrouped \y in {\paramA,...,\paramE} {%. The main drawback with this is when I need to change the number of parameters.

May someone have a more elegant way for using a predefined parameter list that can be used for every loop type like \foreach, \pgfplotsforeachungrouped and \pgfplotsinvokeforeach. Any hint is much appreciated!

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You can use \pgfplotsinvokeforeach with a bit of \expandafter-trickery:

\documentclass[border=1mm]{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.8}

\pgfplotstableread{
1
2
3
4
5
}\dataQuad

\newcommand{\param}{2,3,4,5}

\expandafter\pgfplotsinvokeforeach\expandafter{\param}{%
    \pgfplotstablecreatecol[
        create col/expr={\thisrow{0}^#1}
    ]{#1}\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}
share|improve this answer
    
Thanks again! That approach is more elegant... –  Paul Aug 7 '13 at 19:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.