# Positioning of named nodes and paths within groupplot environments

I am having issues with pgf, pgfplots and the groupplots library. The issue is best explained with an example

\documentclass[tikz]{standalone}
\usepackage{pgfplots}

%\pgfplotsset{compat=1.12}

\begin{document}

\pgfplotsset{compat=1.12}

\usetikzlibrary{intersections}
\usepgfplotslibrary{groupplots}

\begin{tikzpicture}

\begin{groupplot}[group/group size=1 by 2]

\nextgroupplot

% I can do stuff with 'first node' here.
\draw (first node) circle(5pt);

\nextgroupplot
\addplot[name path=my plot] {x^2} node[pos=0.5, name=second node]{};

% Of course, second node works here
\draw (second node) circle(5pt);

% This is not right
\draw (first node) node {huh?} -- (second node);

\end{groupplot}

% This does work!
\draw[dotted, name path=vertical line] (first node) -- (second node);

% But this is not right
\path[name intersections={of={vertical line and my plot}}] (intersection-1) node {x};

\end{tikzpicture}
\end{document}


Thus my questions(s):

• Why is the first node positioned incorrectly at first, but correctly outside the groupplots scope?
• What is going on with the intersection point? Again the document compiles, but the placement is anything but correct.
• Is there a preferred way of connecting plot points between successive \nextgroupplot? This is essentially what I am trying to accomplish.
• Between \nextgroupplot your are effectively inside \begin{axis} environments. Generally you should only draw stuff that belongs to two axis outside in a common scope. As you find in this case it needs to be outside the groupplot env, for exactly the same reasons. – zeroth May 18 '15 at 20:16
• @zeroth Any chance of an answer? – Torbjørn T. Jan 22 '16 at 22:54

In general if you want to do intra-graphics you should do so outside the axis environments.
In this case it is important to recognize that the groupplot environment is a wrapper for several axis environments. Hence you should do your drawings after the \end{groupplot}. This you have already shown and figured out.