Menu

#137 [groupplots] `group style` does not work in (other) styles

v1.0 (example)
open
groupplots (7)
6
2017-06-01
2016-10-09
No

As is stated at http://tex.stackexchange.com/questions/239794/group-style-key-does-not-work-in-pgfplotsset group style cannot be used (directly) in other styles. Do you (Christian) have an idea how to fix this?

I guess this is because there currently isn't a style like every groupplot or similar, right?

And here the copied MWE

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary[pgfplots.groupplots,calc]

\pgfplotsset{
  compat=1.12,
  mygroup/.style={
    group style={
      group size=1 by 2,
      vertical sep=1cm,
    },
    every axis plot/.append style={
      smooth,
    }
  },
  mygroupb/.style={
    group/group size=1 by 2,
    group/vertical sep=1cm,
    every axis plot/.append style={
      smooth,
    }
  },
}

\begin{document}

\begin{figure}
  \centering
  \begin{tikzpicture}
    \begin{groupplot}[
        % This style works without "group style"
        % mygroupb,
        % This style doesn't apply "group style"
         mygroup,
        % But adding it manually here works
        % group style={
        %   group size=1 by 2,
        %   vertical sep=1cm,
        % },
      ]  
      \nextgroupplot
        \addplot+[samples=5,domain=-3:3] {exp(-x^2+1)};
        \addplot+[samples=5,domain=-3:3] {exp(-x^2)};
        \addplot+[samples=5,domain=-3:3] {exp(-x^2-1)};

      \nextgroupplot
        \addplot+[samples=5,domain=-3:3] {exp(-x^2+1)};
        \addplot+[samples=5,domain=-3:3] {exp(-x^2)};
        \addplot+[samples=5,domain=-3:3] {exp(-x^2-1)};
    \end{groupplot}
  \end{tikzpicture}
\end{figure}

\end{document}

And here is another question, where such a style would be useful:

Discussion