File Exchange

image thumbnail

Break X Axis

version 1.2 (22.1 KB) by

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

4.92857
16 Ratings

69 Downloads

Updated

View License

Features
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

Limitations
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.

Comments and Ratings (21)

mh

mh (view profile)

Karl

Karl (view profile)

This doesn't seem to work with the MATLAB function "datetick". Specifically, the dates on the right side of the are wrong while the dates on the left side are correct. This is possibly related to Wenzhen's comment about XTickLabels.

Real life saver. Extremely easy to use, and produce exactly what I wanted - a break in the axis. Thanks for this!

Amazing work! It's exactly what I am looking for. Thanks for making it available!

Liam Daly

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])

sagie brodsky

why does the legend disappears?

SH

SH (view profile)

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

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.

physicsnh

physicsnh

Thank you!

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?

harbm

harbm (view profile)

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

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.

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.

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

Mark

Mark (view profile)

Pretty awesome extension, easy to use.

Updates

1.2

Added a screen shot

1.1

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

MATLAB Release
MATLAB 8.1 (R2013a)
Acknowledgements

Inspired by: BreakAxis, BreakXAxis, BreakPlot

Inspired: Break Y Axis, Aesethetic Axis Breaks

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

» Watch video