[Tex/LaTex] Axis break in pgfplots

pgfplotstikz-pgf

Is there an easy way to 'break' the axis in a pgfplots environment? What I'm talking about is something like this

enter image description here

Any minimal plot will do as an example…for example

\documentclass{minimal}  
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[ymin=0, ymax=80]
\addplot {x*0}; 
\addplot {x^2+50};
\end{axis}
\end{tikzpicture}

\end{document}

For example, in the below plot,

plot

I want to break the axis from around y = 10 to y = 40.

Any ideas? Does PGF have this functionality? A search for `break' in the manual doesn't yield anything.

Best Answer

One solution for the posted minimal example could be the following:

\documentclass{minimal}  
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}

\begin{document}
\pgfplotsset{
% override style for non-boxed plots
    % which is the case for both sub-plots
    every non boxed x axis/.style={} 
}
\begin{tikzpicture}
\begin{groupplot}[
    group style={
        group name=my fancy plots,
        group size=1 by 2,
        xticklabels at=edge bottom,
        vertical sep=0pt
    },
    width=8.5cm,
    xmin=-6, xmax=6
]

\nextgroupplot[ymin=45,ymax=80,
               ytick={60,80},
               axis x line=top, 
               axis y discontinuity=parallel,
               height=4.5cm]
\addplot {x*0};     
\addplot {x^2+50};         

\nextgroupplot[ymin=0,ymax=5,
               ytick={0},
               axis x line=bottom,
               height=2.0cm]
\addplot {x*0}; 
\addplot {x^2+50};                 
\end{groupplot}
\end{tikzpicture}

\end{document}

It combines two plots in a groupplot-environment and plots them on top of each other. Using the axis y discontinuity is possible then:

Two plots using axis y discontinuity for the upper.