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


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


For example, in the below 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.

  • 2
    You can search for axis y discontinuity in the pgfplots manual. – percusse Mar 1 '12 at 23:03
  • 1
    The axis y discontinuity option won't let you plot values near the origin, it is only meant for showing that a plot doesn't start near zero. TSGM, could you provide a more concrete example of what you want to achieve? A break in a column plot is much easier than in a line plot. – Jake Mar 1 '12 at 23:10
  • @Jake: I've edited the original post to be more specific for what kind of break I want to achieve. – TSGM Mar 1 '12 at 23:19
  • I've posted a related question here – Enrico Maria De Angelis Dec 18 '15 at 10:58
  • I've created a feature request ticket on sourceforge sourceforge.net/p/pgfplots/feature-requests/81 – Dilawar Jul 10 '18 at 4:34

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


% override style for non-boxed plots
    % which is the case for both sub-plots
    every non boxed x axis/.style={} 
    group style={
        group name=my fancy plots,
        group size=1 by 2,
        xticklabels at=edge bottom,
        vertical sep=0pt
    xmin=-6, xmax=6

               axis x line=top, 
               axis y discontinuity=parallel,
\addplot {x*0};     
\addplot {x^2+50};         

               axis x line=bottom,
\addplot {x*0}; 
\addplot {x^2+50};                 


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.

  • Ah yes, that's very clever! Would you mind adding a sentence or two describing the approach? – Jake Jul 9 '12 at 22:58
  • 1
    The basic idea is to disable the "boxed" style when gluing two group plots together while setting vertical sep to 0. Then you can define individual axis x line for the upper and lower plot which results in the whole groupplot appearing as one box. – Michi Jul 11 '12 at 10:15
  • I extended this answer here: tex.stackexchange.com/questions/46422 – Dr. Manuel Kuehner Dec 19 '15 at 23:03

Is there an easy way ...

The only "easy" ways to accomplish axis discontinuities are the axis y discontinuity feature mentioned by percusse - which is unavailable for your specific use-case.

Your use-case would need a much more sophisticated implementation which

  • maps coordinates
  • draws discontinuity markers at the correct places into the axis
  • knows how to draw such markers into each bar (and knows how to draw it for other plot handlers as well).

In short: the feature is unavailable. You can post a feature request on sourceforge.

If you are a power-user, you could consider implementing the first two steps using a custom coordinate transformation and some decoration for the axis.

  • 3
    Follow up, is there any guru who can solve this problem? – user14024 Apr 28 '12 at 1:29
  • Plus one with Nadim's request – Rave May 28 '12 at 16:08
  • I also need to accomplish something like this. My use case is nearly identical to the excel image in the OP. – Trevor Aug 20 '12 at 23:14
  • 3
    Nice feature request. I would need it myself. – Pygmalion Aug 27 '12 at 15:28
  • There is another problem: if using scaled ticks, say scaled y ticks=base 10:2, I get an annoying 10^{-2} on both y axes. – Francisco Dec 3 '12 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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