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







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

    \addplot {x} node[pos=0.5, name=first node]{};

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

    \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);


% 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};



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.
  • 1
    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

This arises due to doing operations local within an axis environment which might change scales etc.

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.

An intersection is another matter. The problem here is that each axis changes the coordinate system, individually, and the intersection library stores those paths in some form. Here it seems like the scales of the coordinate system is not updated. You may be required to do this in another way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.