I would like to put both a pgf plot other tikz elements in the same figure, but I cannot figure out what is the height and the width of the plot, so that I can scale other elements to it. Here is an example. As you can see, I could add the element, but found the right size trying values more or less randomly.
\documentclass[11pt]{minimal}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymin=0, ymax=20,
xmin=0, xmax=8,
every axis y label/.style={
at={(ticklabel* cs:1.05)},
anchor=south west,
},
ytick={0,5,11,15,20},
yticklabels={0,5,\textcolor{blue}{$\pi_e^s$},\textcolor{red}{$\pi_e^p$},20},
]
\addplot[mark=x, blue, very thick, domain=0:8] {7*sin(x*90)+10};
\end{axis}
\draw [->, red] (7.5,0) -- (7.5, 5.7) node[midway, right]{\textcolor{red}{foo}};
\end{tikzpicture}
\end{document}
The resulting figure is here:



\pgfkeysvalueof. See question http://tex.stackexchange.com/questions/276211/pgfplots-accessing-the-width-of-a-diagram-and-using-it-as-a-variable-for-other. – Zarko Nov 04 '15 at 16:45