3

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,
]
\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}

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

enter image description here

The unwanted space disappears, if I remove the line

axis x line=top,

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

enter image description here

Is this a bug?

  • 1
    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. – LaRiFaRi 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 :-) – Endzone Sep 15 '15 at 16:53
1

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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.