[Tex/LaTex] title of sub plots with ybar groupplots

pgfplotsspacing

I tried to use groupplots to arrange several bar plots but the titles are drawn on top of the axis labels of the plot above. Am I doing something wrong here?

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}

\begin{document}
  \begin{tikzpicture}
    \begin{groupplot}[group style={group size=2 by 2},width=0.45\textwidth,ybar]
      \nextgroupplot[title=title 1-1]
        \addplot coordinates { (1,1) (42,23)};
      \nextgroupplot[title=title 1-2]
        \addplot coordinates { (1,1) (42,23)};
      \nextgroupplot[title=title 2-1]
        \addplot coordinates { (1,1) (42,23)};
      \nextgroupplot[title=title 2-2]
        \addplot coordinates { (1,1) (42,23)};
    \end{groupplot}
  \end{tikzpicture}
\end{document}

Titles of sub plots

Edit: maybe I should also mention why I'm specifically asking for ybar plots. I tried the same example without the ybar and the spacing was different. The title fits below the axis label without this option but the spacing still looked off. Anyway, I need bar plots so I cannot remove this option.

Best Answer

Use the vertical sep=<length> option to increase the vertical spacing:

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}

\begin{document}
  \begin{tikzpicture}
    \begin{groupplot}[group style={group size=2 by 2,vertical sep= 1.5cm},width=0.45\textwidth,ybar]
      \nextgroupplot[title=title 1-1]
        \addplot coordinates { (1,1) (42,23)};
      \nextgroupplot[title=title 1-2]
        \addplot coordinates { (1,1) (42,23)};
      \nextgroupplot[title=title 2-1]
        \addplot coordinates { (1,1) (42,23)};
      \nextgroupplot[title=title 2-2]
        \addplot coordinates { (1,1) (42,23)};
    \end{groupplot}
  \end{tikzpicture}
\end{document}

enter image description here