# Create groupplot 3 x 6

I asked a similar question before: Create 2x2 groupplot with +1 plot to the side?

For that time using the subfigure environment wasn't a problem. But I do not want to use the subfigure environment now, so I am looking for a different solution. The plot I want to create is:

|-----------------|
|        | Plot 4 |
| Plot 1 |--------|
|        | Plot 5 |
|-----------------|
|        | Plot 6 |
| Plot 2 |--------|
|        | Plot 7 |
|-----------------|
|        | Plot 8 |
| Plot 3 |--------|
|        | Plot 9 |
|-----------------|


Plot 1,2,3 have namely the same x-axis (and for those interested it is a impulse response plot), as well as the plots 4,..,9 (which are bode plots, magnitude + phase).

Does anyone have any idea? I think groupplots should be extend to have some tabular capabilities.

If you are looking for a minimal example I don't have really one since I do not know how to create this but the code of the solution of my previous question might get you started, https://tex.stackexchange.com/a/117685/15360

ps. btw the solution does not necessarly have to be using the groupplot environment. The main reason I use groupplot very often because I know then that the alignment is good. Also when you show the x- and ylabels aswell as the ticks of x and y. So it is meanly about that the alignment is correct.

## 2 Answers

You could use two groupplots environments, where the height of the axes in the second is half that of the first. To align them properly I placed the first sub-plot of the second groupplot relative to the first groupplot, with

\nextgroupplot[anchor=north west, at={($(left plots c1r1.north east) + (0.2cm,0)$)}]


left plots is a label for the first groupplot, added with

group style={
group name=left plots,
..
}


and left plots c1r1 is the axis that is in the first column and first row of the group.

I used the ($(a) + (b)$) syntax from the calc library as ([xshift=0.2cm]left plots c1r1.north east) didn't work.

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}
\begin{groupplot}[
group style={
group name=left plots,
group size=1 by 3,
vertical sep=0pt,
x descriptions at=edge bottom},
width=4cm,
height=4cm,
scale only axis]
\nextgroupplot
\addplot {x^2};
\nextgroupplot
\addplot {x^2};
\nextgroupplot
\addplot {x^2};
\end{groupplot}

\begin{groupplot}[
group style={
group size=1 by 6,
vertical sep=0pt,
x descriptions at=edge bottom},
width=4cm,
height=2cm,
scale only axis,
ytick pos=right]
\nextgroupplot[anchor=north west, at={($(left plots c1r1.north east) + (0.2cm,0)$)}]
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x};
\end{groupplot}
\end{tikzpicture}

\end{document}


# Old answer

I would like a groupplots only solution, but a workaround is to use two tikzpictures each having a groupplot environment, where the height of the axes in the second is half the height of those in the first.

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}

\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=1 by 3,
vertical sep=0pt,
x descriptions at=edge bottom},
width=4cm,
height=4cm,
scale only axis]
\nextgroupplot
\addplot {x^2};
\nextgroupplot
\addplot {x^2};
\nextgroupplot
\addplot {x^2};
\end{groupplot}
\end{tikzpicture}
%
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=1 by 6,
vertical sep=0pt,
x descriptions at=edge bottom},
width=4cm,
height=2cm,
scale only axis,
ytick pos=right]
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x)};
\nextgroupplot
\addplot {sqrt(x};
\end{groupplot}
\end{tikzpicture}

\end{document}


It is also possible to do this inside a single 2x6 grouplot by grouping 2 by 2 the graphs of the left column:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}

\begin{document}

\begin{tikzpicture}
\pgfplotsset{
% override style for non-boxed plots
% which is the case for both sub-plots
every non boxed x axis/.style={},
rightGraph/.style={ytick pos=right},
leftUpperGraph/.style={ axis x line=top, ymin=10,ymax=20, xmin=-5,xmax=5, ytick={12,14,...,18}, %To remove one of the two 10 so it doesn't look bold.
},
leftLowerGraph/.style={ axis x line=bottom, ymin=0,ymax=10, xmin=-5,xmax=5,},
}
\begin{groupplot}[
group style={
group size=2 by 6,
vertical sep=0pt,
horizontal sep=2mm,
x descriptions at=edge bottom},
width=4cm,
height=2cm,
scale only axis]
\nextgroupplot[%
leftUpperGraph,
]
\addplot {x^2};
\nextgroupplot[%
rightGraph,
]
\addplot {sqrt(x)};
\nextgroupplot[%
leftLowerGraph,
]
\addplot {x^2};
\nextgroupplot[%
rightGraph,
]
\addplot {sqrt(x)};
\nextgroupplot[%
leftUpperGraph,
]
\addplot {x^2};
\nextgroupplot[%
rightGraph,
]
\addplot {sqrt(x)};
\nextgroupplot[%
leftLowerGraph,
]
\addplot {x^2};
\nextgroupplot[%
rightGraph,
]
\addplot {sqrt(x)};
\nextgroupplot[%
leftUpperGraph,
]
\addplot {x^2};
\nextgroupplot[%
rightGraph,
]
\addplot {sqrt(x)};
\nextgroupplot[%
leftLowerGraph,
]
\addplot {x^2};
\nextgroupplot[%
rightGraph,
]
\addplot {sqrt(x)};
\end{groupplot}
\end{tikzpicture}

\end{document}


I haven't write any groupplots in months (other than this one^^) so I have a bonus question: how can I define a style for a groupplot, \tikzstyle doesn't work… This would make my code a bit shorter :)

### Edit:

An answer have be given by Torbjørn T. so I updated my answer accordingly introducing styles.

• You can use e.g. mygroupstyle/.style={ytick pos=right} inside \pgfplotsset. Using \tikzstyle is, I think, discouraged in favour of \tikzset{stylename/.style={}} anyway. – Torbjørn T. Oct 27 '15 at 21:23
• @torbjørn-t thanks, I've updated my answer accordingly. – Vser Oct 27 '15 at 22:07