# Vertically stacked group plot with different horizontal scaling

I've 4 data sets that I'd like to present as a stack using pgfplots' groupplot library. What I'm struggling with is that the first data set has a larger horizontal range to the remaining three. I'd like to minimize the range of each data set so as to most clearly show my data, meaning that using the larger range of the first data set for all the plots is not acceptable to me.

My question is: how can I display the relevant x tick labels under the first graph and last, but not under the second and third? MWE below.

\documentclass{standalone}

\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}

\begin{document}

\pgfplotsset{
cycle list={
{black,thin},
},
/pgf/text mark/style={mark=none},
}

\begin{tikzpicture}
\begin{groupplot}[
group style={
group name=my plots,
group size=1 by 4,
xlabels at=edge bottom,
xticklabels at=edge bottom,
vertical sep=5pt
},
footnotesize,
xmin=0, xmax=90,
ymin=0, ymax=7
.0,
xtick={0,5,...,100},
ytick={0,0.5,...,7.0},
minor x tick num=4,
minor y tick num=4,
]

\nextgroupplot[ytick={0,1,...,7}]
\addplot coordinates { (0.1,6.9) (44.5,4.8) (89.9,0.01) };

\nextgroupplot[xmin=35,xmax=70,ymax=1.7]
\addplot coordinates { (35.1,1.6) (55.2,1.3) (69,0.01) };

\nextgroupplot[xmin=35,xmax=70,ymin=0.5,ymax=2.1]
\addplot coordinates { (35.1,1.8) (69,1.6) };

\nextgroupplot[xmin=35,xmax=70,ymax=1.1]
\addplot coordinates { (35.1,0.75) (69,0.75) };

\end{groupplot}
\end{tikzpicture}

\end{document}
• Honestly it's more confusing that helping to have several vertically stacked plots with different horizontal scales... – s__C Apr 7 '15 at 16:00
• @s__C in general, I completely agree with you. However, I don't intended for the data to be directly compared so I think it's ok. – Dai Apr 8 '15 at 12:02

Another answer with better spacing between subplots:

\documentclass{standalone}

\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}

\begin{document}

\pgfplotsset{
cycle list={
{black,thin},
},
/pgf/text mark/style={mark=none},
}

\begin{tikzpicture}
\begin{groupplot}[
group style={
group name=my plots,
group size=1 by 4,
vertical sep=2pt
},
footnotesize,
xmin=0, xmax=90,
ymin=0, ymax=7
.0,
%xtick={0,5,...,100},
ytick={0,0.5,...,7.0},
minor x tick num=4,
minor y tick num=4,
]

\nextgroupplot[ytick={0,1,...,7}]
\addplot coordinates { (0.1,6.9) (44.5,4.8) (89.9,0.01) };

\nextgroupplot[xmin=35,xmax=70,ymax=1.7, xticklabels=\empty, yshift=-1em]
\addplot coordinates { (35.1,1.6) (55.2,1.3) (69,0.01) };

\nextgroupplot[xmin=35,xmax=70,ymin=0.5,ymax=2.1, xticklabels=\empty]
\addplot coordinates { (35.1,1.8) (69,1.6) };

\nextgroupplot[xmin=35,xmax=70,ymax=1.1]
\addplot coordinates { (35.1,0.75) (69,0.75) };

\end{groupplot}
\end{tikzpicture}

\end{document}

You can make xtick=\empty in 2nd and 3rd plots and for first and last, give them explicitly. Disable

xlabels at=edge bottom,
xticklabels at=edge bottom,

BTW.

Code:

\documentclass{standalone}

\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}

\begin{document}

\pgfplotsset{
compat=1.12,
cycle list={
{black,thin},
},
/pgf/text mark/style={mark=none},
}

\begin{tikzpicture}
\begin{groupplot}[
group style={
group name=my plots,
group size=1 by 4,
%xlabels at=edge bottom,
%        xticklabels at=edge bottom,
vertical sep=12pt
},
footnotesize,
xmin=0, xmax=100,
ymin=0, ymax=7
.0,
xtick={0,5,...,100},
ytick={0,0.5,...,7.0},
minor x tick num=4,
minor y tick num=4,
]

\nextgroupplot[ytick={0,1,...,7},xtick={0,20,...,100}]
\addplot coordinates { (0.1,6.9) (44.5,4.8) (99.9,0.01) };

\nextgroupplot[xmin=35,xmax=70,ymax=1.7,xtick=\empty]
\addplot coordinates { (35.1,1.6) (55.2,1.3) (69,0.01) };

\nextgroupplot[xmin=35,xmax=70,ymin=0.5,ymax=2.1,xtick=\empty]
\addplot coordinates { (35.1,1.8) (69,1.6) };

\nextgroupplot[xmin=35,xmax=70,ymax=1.1]
\addplot coordinates { (35.1,0.75) (69,0.75) };

\end{groupplot}
\end{tikzpicture}

\end{document}

I have changed the vertical sep to accommodate the labels under first graph.