# Unwanted vertical space above x-axis in TikZ + pgfplots + groupplot

I'm using TikZ with groupplot to merge two plots vertically and thus I need to remove the

• lower x-axis line on the upper plot
• upper x-axis line on the lower plot.

This is achieved with this MWE:

\documentclass[a4paper]{article}
\usepackage{tikz,pgfplots}
\usetikzlibrary{pgfplots.groupplots}
\begin{document}
%
\begin{tikzpicture}
\pgfplotsset{every non boxed x axis/.style={}}
\begin{groupplot}[%
group style={%
group size=1 by 2,%
x descriptions at=edge bottom,%
vertical sep=0pt,%
},%
xmin=-1,xmax=254,
yminorgrids,
]
%
\nextgroupplot[ymin=90,ymax=99,
axis x line=top,
axis y discontinuity=crunch,
]
table[row sep=crcr]{%
-1 96\\
};
%
\nextgroupplot[
ymin=0,
ymax=50,
axis x line=bottom,
]
table[row sep=crcr]{%
125 13\\
};
\end{groupplot}
\draw [blue] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\end{document}


Unfortunately, I get an unwanted vertical gap between the upper bounding box (blue line) and the upper x-axis, see:

The unwanted space disappears, if I remove the line

axis x line=top,


but then the x-axis of the upper plot reappears.

Is this a bug?

• You are missing xmajorticks=false, in your first plot. You might want to report that x descriptions at=edge bottom, should set that by default. Would be a better solution IMO. Sep 15 '15 at 12:23
• @LaRiFaRi, thank you. Adding xmajorticks=false makes the space disappear. I will report the problem, once I find the time :-) Sep 15 '15 at 16:53

As mentioned in comment, you have to toggle the usage of xmajorticks in your first plot like here:

% arara: pdflatex

\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.13}

\begin{document}
\begin{tikzpicture}
\begin{groupplot}[%
,group style={%
,group size=1 by 2
,x descriptions at=edge bottom
,vertical sep=0pt
}
,xmin=-1,xmax=254
,yminorgrids
]
\nextgroupplot[%
,ymin=90.01,ymax=99
,axis x line=top
,axis y discontinuity=crunch
,xmajorticks=false
]
\addplot [only marks] table[row sep=crcr]{-1 96\\};
\nextgroupplot[%
,ymin=0,ymax=50
,axis x line=bottom
]
\addplot [only marks] table[row sep=crcr]{125 13\\};
\end{groupplot}
\draw [blue] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\end{document}