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
  • 2
    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
    – Enlico
    Dec 18 '15 at 10:58
  • 2
    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.
    – der Michi
    Jul 11 '12 at 10:15
  • I extended this answer here: tex.stackexchange.com/questions/46422 Dec 19 '15 at 23:03
  • I have 3 levels of plots with grids. To hide x-axes in the plot interior, the middle one must have a combination of commands: x axis line style={draw opacity=0}, axis x line*=none.
    – forrest
    Apr 19 '20 at 8:53

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.

  • 4
    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
  • 5
    Nice feature request. I would need it myself.
    – Pygmalion
    Aug 27 '12 at 15:28
  • 4
    @christian I was wondering if this capability has been added since this question was asked a long time ago? Thanks.
    – Ali
    Jan 21 '20 at 3:45

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.