我正在使用 Ti钾Zgroupplot
垂直合并两个图,因此我需要删除
- 上图下方的 x 轴线
- 下图中的上方 x 轴线。
这是通过以下 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}
不幸的是,上边界框(蓝线)和上 x 轴之间出现了不必要的垂直间隙,参见:
如果我删除该行,不需要的空间就会消失
axis x line=top,
但随后上图的 x 轴又重新出现。
这是一个错误吗?
答案1
正如评论中提到的,您必须在第一个图中切换使用,xmajorticks
如下所示:
% 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}