View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Break X Axis

5.0 | 9 ratings Rate this file 78 Downloads (last 30 days) File Size: 22.1 KB File ID: #42905 Version: 1.2
image thumbnail

Break X Axis


Peter (view profile)


01 Aug 2013 (Updated )

Splits the x-axis into 2 disjoint regions in order to hide an uninteresting portion of a figure.

| Watch this File

File Information

1.) Minimal fuss, just works
2.) Professional looking graphs
3.) Works with all 2D graphics objects: Lines, Text, Patches, Images, etc.
5.) Obeys ‘XTickMode’ for automatic or manual positioning of tick marks.
6.) Obeys ‘Layer’ property
7.) Works with semilogy plots and with either axis reversed
8.) Can resize after splitting axis
8.) Possible to unsplit axis

1.) No support for semilogx or loglog plots
2.) Creates extra copies of the data which may be problematic when displaying very large data sets.
3.) Text inside an axes must have 'Clipping' turned 'Off' or be added after splitting the axis. Otherwise it may be rendered twice. See TextExample.m for more details.


Break Axis, Break X Axis, and Break Plot inspired this file.

This file inspired Break Y Axis and Aesethetic Axis Breaks.

Required Products MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (14)
09 Jan 2017 Rene Werner

@ multiple breaks (as I had the the same question): Just run the code iteratively, i.e. replace the line

h = breakxaxis([2 3]);

in the "SimpleExample.m" by

h = breakxaxis([2 3]);
hh = breakxaxis(h.rightAxes , [3.7 4.2])
hhh = breakxaxis(hh.rightAxes , [4.5 4.8])

30 Nov 2016 sagie brodsky

why does the legend disappears?

Comment only
10 Aug 2016 SH

SH (view profile)

This worked great until 2014b came out.... Does anyone know how to fix this??? Peter, PLEASE!!! Thanks in advance >_>^

Comment only
02 Aug 2016 imtiyaz

Thanks for sharing. But I don't want to this whole break visible I just want --//-- in my x-axis. Can you suggest how is it possible through your function.

Comment only
01 May 2016 Wei-Zhong Tan

22 Jan 2016 physicsnh

22 Jan 2016 physicsnh

Thank you!

04 Dec 2015 Ming Wu

The legend seems to disappear behind the plot (becoming invisible) using the Matlab 2015a version. I've tried a few things to fix this but nothing seems to work. Does anyone have any ideas to fix this?

Comment only
10 Mar 2015 harbm

harbm (view profile)

This is a great, good looking, fool proof and easy to use function. Good job!

11 Sep 2014 Wenzhen

Thanks! It's a nice and convenient function. However, there is a little bug about making the XTickLabel. In the main function, you've rearranged the XTick array, but not the XTickLabel array. As far as adding a similar line to the XTick array part, the problem would be fixed.

27 Feb 2014 Arturo Moncada-Torres

26 Feb 2014 Mar

Mar (view profile)

Thanks it's very useful, great!!
I have one question. When i make two breaks in the same plot the axes left and right don't keep the x scale. Do you know if is it possible to keep it?
Thank you very much.

04 Feb 2014 Peter T. S. DeVore

Would be nice if it could support multiple breaks. I, in particular, need that.

Comment only
26 Sep 2013 Mark

Mark (view profile)

Pretty awesome extension, easy to use.

05 Aug 2013 1.1

Fixed a bug that caused plots to be misaligned in some complex figures.

06 Aug 2013 1.2

Added a screen shot

Contact us