TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to have some kind of jump on the axis of the plot in pgfplots package. Something similar to the following figure where some part of the scales are jammed.

enter image description here

It would be interesting to have even different scales for the top and botoom traces (exactly like the figure).

Any idea is appreciated.

share|improve this question
up vote 15 down vote accepted

You can simply use two axes that you position relative to each other.

Here's an example where I've defined a new key axis break gap that can be used to set the gap between the axes:

    axis break gap/.initial=1mm
            name=bottom axis,
            domain = 0:pi,
            scale only axis,
            width=8cm, height=4cm,
            axis x line*=bottom
            \addplot [smooth] {-cos(deg(x))^6/10+0.2};
            \addplot [smooth] {-cos(deg(x))^6/10+0.4};
            at=(bottom axis.north),
            anchor=south, yshift=\pgfkeysvalueof{/tikz/axis break gap},
            domain = 0:pi,
            scale only axis,
            width=8cm, height=4cm,
            axis x line*=top,
            after end axis/.code={
                \draw (rel axis cs:0,0) +(-2mm,-1mm) -- +(2mm,1mm)
                    ++(0pt,-\pgfkeysvalueof{/tikz/axis break gap})
                    +(-2mm,-1mm) -- +(2mm,1mm)
                    (rel axis cs:1,0) +(-2mm,-1mm) -- +(2mm,1mm)
                    ++(0pt,-\pgfkeysvalueof{/tikz/axis break gap})
                    +(-2mm,-1mm) -- +(2mm,1mm);
            \addplot [smooth] {-cos(deg(x))^6+2};
            \addplot [smooth] {-cos(deg(x))^6+4};
share|improve this answer
Thanks Jake. This is exactly what I needed. – antmw1361 Jan 24 '13 at 7:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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