# pgfplots - divide y-axis in 2 parts

I have a plot, code here. Now the problem I have is that because of the scale of y-axis it looks as if the plots are actually just 3 lines. Now what I want is that the y-axis is sort of splitted. Into a section ranging from -0.2 to 0.2 and a part ranging from -1.5 to -1.3...

So the y-axis would look like something

 0.2 -|
|
|
-0.2 -|
|
-1.3 -|
|
|
-1.5 -|
----------------------------


Is this possible?

-- Okay I see there is a workaround for this using groupplots. But the plot that I give, I was already going to use this inside a groupplot environment with 2 other plots. So can I also use the suggested method in combinations with other normal plots which are combined in a groupplot.

My current setup, now I need the splitting for the third groupplot

\begin{tikzpicture}

\pgfplotsset{%
width=4cm,
height=4cm,
scale only axis,
every x tick label/.append style={font=\scriptsize\color{gray!80!black}},
xmajorgrids,
xminorgrids,
every y tick label/.append style={font=\scriptsize\color{gray!80!black}},
ymajorgrids,
yminorgrids
}

\begin{groupplot}[%
group style={
group size=3 by 1,
horizontal sep=50pt,
vertical sep=40pt
}
]

\nextgroupplot[
xmin=0,
xmax=800,
xlabel={Time [\si{\second}]},
ymin=-0.000196069528802578,
ymax=0.000140838393117182,
ylabel={State error $\mathbf{x} - \mathbf{x}'$},
]

color=red,
solid,
forget plot
]
table[row sep=crcr]{
};

color=green,
solid,
forget plot
]
table[row sep=crcr]{
};

color=blue,
solid,
forget plot
]
table[row sep=crcr]{
};

\nextgroupplot[
xmin=0,
xmax=800,
xlabel={Time [\si{\second}]},
ymin=-3.50920459213846,
ymax=2.98111910953132,
ylabel={$||\delta(t)||/{\delta_0}$}
]
color=blue,
solid,
forget plot
]
table[row sep=crcr]{
};

\nextgroupplot[
xmin=0.5,
xmax=800,
xlabel={Time [\si{\second}]},
ymin=-1.35665432608546,
ymax=0.168623669468375,
ylabel={Lyapunov exponents},
]
color=blue,
solid,
forget plot
]
};
color=green!50!black,
solid,
forget plot
]
table[row sep=crcr]{
};
color=red,
solid,
forget plot
]
table[row sep=crcr]{
};

\end{groupplot}

\end{tikzpicture}%


Let me also note that I need a common y-label, so this solutions to it should be able to work... Create x and y label which overlaps for multiple plots

• Have a look at Axis break in pgfplots. This might help. – Johannes_B Nov 20 '13 at 19:29
• Could you create a minimal example document that demonstrates your setup? – Jake Nov 20 '13 at 20:46
• @Jake here you go. – WG- Nov 20 '13 at 20:54

Here is a suggestion. I use a second groupplot environment for the third axis, and place it relative to the second axis. For the ylabel I simply used shift to move it down a bit. For the third axis, note that the height is set explicitly for each of the groupplots, so that their combined height is the same as the other axes (4cm).

\documentclass[border=5mm,tikz]{standalone}
\usepackage{pgfplots,siunitx}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}

\pgfplotsset{%
width=4cm,
height=4cm,
scale only axis,
every x tick label/.append style={font=\scriptsize\color{gray!80!black}},
xmajorgrids,
xminorgrids,
every y tick label/.append style={font=\scriptsize\color{gray!80!black}},
ymajorgrids,
yminorgrids
}

\begin{groupplot}[%
group style={
group name=first,
group size=2 by 1,
horizontal sep=50pt,
vertical sep=40pt
}
]

\nextgroupplot[
xmin=0,
xmax=800,
xlabel={Time [\si{\second}]},
ymin=-0.000196069528802578,
ymax=0.000140838393117182,
ylabel={State error $\mathbf{x} - \mathbf{x}'$},
]

\nextgroupplot[
xmin=0,
xmax=800,
xlabel={Time [\si{\second}]},
ymin=-3.50920459213846,
ymax=2.98111910953132,
ylabel={$||\delta(t)||/{\delta_0}$}
]

\end{groupplot}

\begin{groupplot}[
group style={
group name=second,
group size=1 by 2,
vertical sep=0pt,
x descriptions at=edge bottom},
xmin=0.5,xmax=800,
anchor=north west]

\nextgroupplot[at={($(first c2r1.outer north east)+(40pt,0)$)},
ylabel={Lyapunov exponents},
ylabel style={shift={(-1cm,0)}},
ymin=-0.3,ymax=0.2,
axis x line=top,
axis y discontinuity=parallel,
height=2cm]

\nextgroupplot[ymin=-1.5,ymax=-1.28,xlabel={Time [\si{\second}]},
axis x line=bottom,
height=2cm]

\end{groupplot}

\end{tikzpicture}%
\end{document}