# Print comma instead of period in node near coord

I need to print the Y-values for each point with a comma for decimal seperator. See my MWE. The data is provided as a .csv within my folder.

\documentclass{standalone}
\usepackage{pgfplots,pgfplotstable}
\usepgfplotslibrary{units}
\usepackage{siunitx}
\sisetup{
%strict,
output-decimal-marker={,},
exponent-product=\cdot,
detect-all
}

X   Y
0   0.03
63  0.04
118 0.09
188 0.38
210 0.47
267 0.89
327 1.50
362 1.82
}{\growth}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
/pgf/number format/.cd,
use comma,
width=\linewidth,
grid=major,
grid style={dashed,gray!30},
xlabel=Zeit,
ylabel=Optische Dichte,
x unit=\si{\minute},
y unit=,
ymode=log,
%       xtick={0,100,150,200,300},
x tick label style={rotate=90,anchor=east},
legend cell align=left,
legend pos=north west
]
thick,
mark=*,
mark options={fill=red},
nodes near coords,
point meta=explicit symbolic,
every node near coord/.style={anchor=-40},
color=blue,
] table [x=X,y=Y,col sep=tab,meta index=2] {\growth};
\end{axis}
\end{tikzpicture}
\end{document}


I used thinks like

/pgf/number format/.cd,
use comma,


within the command for every node near coord/.style, but I can't achieve the right format for the decimal seperator.

Your problem is that you've listed point meta=explicit symbolic, which means pgfplots treats the point meta like a string and doesn't use \pgfmathprintnumber for printing. You can instead use the option point meta=explicit (not explicit symbolic) with the /pgf/number format/use comma to get what you want. Note that you need to specify explicit because otherwise, the nodes near coords will print the log transformed value of the y coordinate.

Note that there were some errors with your MWE that I fixed. In particular, the SX site doesn't save tabs, so the specification of your table (col sep=tab) wasn't quite correct (and in any case, I believe that pgfplots treats any whitespace as a column separator, so the specification of tab is not necessary here where there are no spaces between data), and the meta index needed to be 1 not 2.

I also changed your axis to a semilogyaxis instead of using ymode=log and got rid of the /pgf/number format/.cd in the first line of the options, in case it might cause a problem (although to be honest, I don't think it actually does anything there).

\documentclass{standalone}
\usepackage{pgfplots,pgfplotstable}
\pgfplotsset{compat=1.11}
\usepgfplotslibrary{units}
\usepackage{siunitx}
\sisetup{
%strict,
output-decimal-marker={,},
exponent-product=\cdot,
detect-all
}

X   Y
0   0.03
63  0.04
118 0.09
188 0.38
210 0.47
267 0.89
327 1.50
362 1.82
}{\growth}

\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
/pgf/number format/use comma,
width=\linewidth,
grid=major,
grid style={dashed,gray!30},
xlabel=Zeit,
ylabel=Optische Dichte,
x unit=\si{\minute},
y unit=,
%       xtick={0,100,150,200,300},
x tick label style={rotate=90,anchor=east},
legend cell align=left,
legend pos=north west,
]
thick,
mark=*,
mark options={fill=red},
nodes near coords,
point meta=explicit,
every node near coord/.append style={anchor=-40, /pgf/number format/.cd, use comma, fixed, precision=2},
color=blue,
] table [x=X,y=Y,col sep=tab,meta index=1] {\growth};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

• @TechPharmacist Glad to help! – darthbith Jan 20 '15 at 23:46

With all that siunitx settings, you can use

nodes near coords={$\num{\pgfplotspointmeta}$},


Code:

\documentclass{standalone}
\usepackage{pgfplots,pgfplotstable}
\usepgfplotslibrary{units}
\usepackage{siunitx}
\sisetup{
%strict,
output-decimal-marker={,},
exponent-product=\cdot,
detect-all
}

\pgfplotsset{compat=1.11}

X   Y
0   0.03
63  0.04
118 0.09
188 0.38
210 0.47
267 0.89
327 1.50
362 1.82
}{\growth}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
/pgf/number format/.cd,
use comma,
width=\linewidth,
grid=major,
grid style={dashed,gray!30},
xlabel=Zeit,
ylabel=Optische Dichte,
x unit=\si{\minute},
y unit=,
ymode=log,
xtick={0,100,150,200,300},
x tick label style={rotate=90,anchor=east},
legend cell align=left,
legend pos=north west
]
nodes near coords={$\num{\pgfplotspointmeta}$},