1

I have to plot some data as a bar plot. These data is processed with pgfplotstable, so I can plot the mean and the error for my data. Now I want to print the nodes near coords for each of the bars; the only thing I get is an error message. See my code with the data below. I use LuaLaTeX to compile.

TL;DR-Version: Code won't compile when nodes near coords and y error used with the same axis.

\documentclass{standalone}

\usepackage[detect-all=true]{siunitx}
\sisetup{
    output-decimal-marker={,},
    exponent-product=\cdot,
    text-micro={\fontfamily{mdbch}\textmu},
    math-micro=\muup
}

\usepackage{tikz}
\usepackage{pgfplots,pgfplotstable}

%% Code chunk for statistics starts here...
\newcommand{\calcrowmean}{
    \def\rowmean{0}
    \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/summary statistics/end index}-\pgfkeysvalueof{/pgfplots/table/summary statistics/start index}+1}
    \edef\numberofcols{\pgfmathresult}
    % ... loop over all columns, summing up the elements
    \pgfplotsforeachungrouped \col in {\pgfkeysvalueof{/pgfplots/table/summary statistics/start index},...,\pgfkeysvalueof{/pgfplots/table/summary statistics/end index}}{
        \pgfmathparse{\rowmean+\thisrowno{\col}/\numberofcols}
        \edef\rowmean{\pgfmathresult}
    }
}
\newcommand{\calcstddev}{
    \def\rowstddev{0}
    \calcrowmean
    \pgfplotsforeachungrouped \col in {\pgfkeysvalueof{/pgfplots/table/summary statistics/start index},...,\pgfkeysvalueof{/pgfplots/table/summary statistics/end index}}{
        \pgfmathparse{\rowstddev+(\thisrowno{\col}-\rowmean)^2/(\numberofcols-1)}
        \edef\rowstddev{\pgfmathresult}
    }
    \pgfmathparse{sqrt(\rowstddev)}
}
\newcommand{\calcstderror}{
    \calcrowmean
    \calcstddev
    \pgfmathparse{sqrt(\rowstddev)/sqrt(\numberofcols)}
}

\pgfplotstableset{
    summary statistics/start index/.initial=1,
    summary statistics/end index/.initial=4,
    create col/mean/.style={
        /pgfplots/table/create col/assign/.code={% In each row ... 
            \calcrowmean
            \pgfkeyslet{/pgfplots/table/create col/next content}\rowmean
        }
    },
    create col/standard deviation/.style={
        /pgfplots/table/create col/assign/.code={% In each row ... 
            \calcstddev
            \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult
        }
    },
    create col/standard error/.style={
        create col/assign/.code={% In each row ... 
            \calcstderror
            \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult
        }
    }
}
%%...code chunk for statistics ends here

\usepackage{filecontents}
\begin{filecontents*}{data.csv}
    ch  1   2   3   4   5   6   7   8   9   10
    1   528 531 526 529 539 532 524 532 534 528
    2   477 506 454 477 462 458 473 510 480 512
    3   494 457 502 499 466 474 445 471 501 483
    4   525 511 515 524 530 505 527 511 504 528
    5   566 577 579 573 554 579 582 582 583 574
\end{filecontents*}

\begin{document}
    \pgfplotstableset{
        create on use/mean/.style={create col/mean},
        create on use/stddev/.style={create col/standard deviation},
        create on use/stderror/.style={create col/standard error}
    }
    \begin{tikzpicture}
    \begin{axis}[
    ybar,
    ymin=0,
    title={1.4.1a Gleichförmigkeit der Masse},
    /pgf/number format/use comma,
    width=\linewidth,
    grid=major,
    grid style={dashed,gray!30},
    x label style={at={(axis description cs:.5,-.025)},anchor=north},
    y label style={at={(axis description cs:.05,.5)},anchor=south},
    xlabel=Charge,
    ylabel=Masse~{[\si{\gram}]},
    xtick={1,...,5},
    xticklabels={R1,R2,R3,R4,R5},
    legend cell align=left,
    legend pos=north west,
    ]

    \addplot[
    fill=blue,
    draw=black,
    error bars/.cd,
    y dir=both,
    y explicit,
    ]
    table [x=ch,y=mean,y error=stderror] {data.csv};
    \addlegendentry[align=left]{Mittelwerte der Tablettenmasse\\mit Standardabweichung};
    \end{axis}
    \end{tikzpicture}
\end{document}

closed as off-topic by Stefan Pinnow, Zarko, gernot, user36296, Torbjørn T. Nov 2 '16 at 15:33

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Are all those packages and the calculations of the statistics necessary to reproduce the problem? If they aren't, could you edit your question and boil the code down to the absolute minimum that's required to demonstrate the issue? – Jake May 7 '15 at 16:41
  • Most of them are necessary, yes. I'll edit the question and reduce the code. – Ruehrfisch May 7 '15 at 17:19
  • This code compiles fine for me, even if I add nodes near coords to the axis options. What error message do you get? – Jake May 7 '15 at 17:25
  • That's right. Compiles without error for me, too. I can't reproduce the error now. Maybe there is a problem with my laptop, I compiled it there. Sorry for the problems I caused. – Ruehrfisch May 7 '15 at 19:35
  • 5
    I'm voting to close this question as off-topic because OP stated that the problem has vanished (by recompiling). – Stefan Pinnow Nov 2 '16 at 13:39