2

I am using the groupplots library in pgfplots to create plot groupings. I am using the 2x2 sizing but only have 3 plots. How can I center the furthest right plot vertically, to make a triangle rather than an upside down L? In another case, I would like to center the bottom plot horizontally, would this use the same procedure? Is there a better tool to use than groupplots?

\documentclass{standalone}
\usepackage{tikz,pgfplots}
    \usepgfplotslibrary{groupplots}

\begin{document}
  \begin{tikzpicture}
    \begin{groupplot}[
      group style={group size=2 by 2},
      width=4cm, height=4cm,
    ]
    \nextgroupplot
      \addplot coordinates{(0,0) (1,2) (2,1)};
    \nextgroupplot
      \addplot coordinates{(0,0) (1,2) (2,1)};
    \nextgroupplot
      \addplot coordinates{(0,0) (1,2) (2,1)};
    \end{groupplot}
  \end{tikzpicture}
\end{document}
Sean Allred
  • 27,421
ZazK
  • 21
  • 2
    Groupplots really shines when your subplots use the same axes, because it allows you to only show the axes on the edges of the groups. For more general alignments like the one you're looking for, using separate axis or even tikzpicture environments might be a better way to go. – Jake Jul 11 '13 at 17:49

1 Answers1

2

Thanks to Jake's suggestion, a significant compression of my original solution is possible (since I don't know a thing about tikz). Also, a new version of stackengine should hit the streets this weekend. The syntax I used here will work in both old and new versions. You can control the inter-plot separation, if desired (i.e., normal hspacing will work between the top two plots, and an optional length argument to \stackunder will define the vertical gap).

\documentclass{standalone}
\usepackage{stackengine}
\usepackage{tikz,pgfplots}
    \usepgfplotslibrary{groupplots}
\begin{document}
\stackunder{%
  \begin{tikzpicture}
    \begin{axis}[width=4cm, height=4cm] \addplot coordinates{%
      (0,0) (1,2) (2,1)}; \end{axis}
  \end{tikzpicture}
  \begin{tikzpicture}
    \begin{axis}[width=4cm, height=4cm] \addplot coordinates{%
      (0,0) (1,2) (2,1)}; \end{axis}
  \end{tikzpicture}
}{%
  \begin{tikzpicture}
    \begin{axis}[width=4cm, height=4cm] \addplot coordinates{%
      (0,0) (1,2) (2,1)}; \end{axis}
  \end{tikzpicture}
}
\end{document}

enter image description here