I'm trying to place a label above a curve with tikz and pgfplots. My solution below produces the expected output, but only when I ignore the error message during compiling:
Package PGF Error: I cannot decorate an empty path. [ \end{axis}]
What does it mean and how do I fix it? There clearly is a visible path, and it does get decorated when I skip over the error. Example below:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.markings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\pgfmathdeclarefunction{poiss}{1}{%
\pgfmathparse{(#1^x)*exp(-#1)/(x!)}%
}
\begin{tikzpicture}[node distance=10mm]
\begin{axis}[
compat=newest,
ymax=0.16,
xlabel=$k$,
ylabel=$P(k)$,
domain=0:25,samples at = {0,...,25},
label/.style 2 args={%
postaction={ decorate,
decoration={ markings, mark=at position #1 with \node#2;}
}}%
]
\addplot[red,mark=o,%
label={0.45}%
{[above]{$\lambda=10$}}%
] {poiss(10)};
\end{axis}
\end{tikzpicture}
\end{document}
