4.16667
4.2 | 7 ratings Rate this file 67 Downloads (last 30 days) File Size: 2.76 KB File ID: #3668 Version: 1.0

# BreakAxis

### Michael Robbins (view profile)

30 Jun 2003 (Updated )

Produces a plot who's y-axis skips to avoid unecessary blank space.

File Information
Description

BreakPlot(x,y,y_break_start,y_break_end,break_type)
Produces a plot who's y-axis skips to avoid unecessary blank space

INPUT
x
y
y_break_start
y_break_end
break_type
if break_type='RPatch' the plot will look torn
in the broken space
if break_type='Patch' the plot will have a more
regular, zig-zag tear
if break_plot='Line' the plot will merely have
some hash marks on the y-axis to denote the
break

USAGE:
figure;
BreakPlot(rand(1,21),[1:10,40:50],10,40,'Line');
figure;
BreakPlot(rand(1,21),[1:10,40:50],10,40,'Patch');
figure;
BreakPlot(rand(1,21),[1:10,40:50],10,40,'RPatch');
figure;
x=rand(1,21);y=[1:10,40:50];
subplot(2,1,1);plot(x(y>=40),y(y>=40),'.');
set(gca,'XTickLabel',[]);
subplot(2,1,2);plot(x(y<=20),y(y<=20),'.');%

IT'S NOT FANCY, BUT IT WORKS.

Acknowledgements

This file inspired Break X Axis, Break Bar Plot, Break Plot, Break X Axis, and Break Y Axis.

MATLAB release MATLAB 6.5 (R13)
28 Jul 2012 J G

### J G (view profile)

Is it possible to use this for hist function?

Comment only
28 Jul 2012 J G

### J G (view profile)

02 Jun 2008 Peter Lustig

One small addition: If your y data has a large range and you want to skip a lot (e.g. several orders of magnitude), then the mid point might not be suitable for breaking. In my case the upper part got way too much range compared to the lower. Can easily be adjusted by tweaking the 'y_break_mid'. I used e.g.

y_break_mid= y_break_end - (y_break_end-y_break_start)./10;

Great code, helped a lot, Michael!

02 Jun 2008 Peter Lustig

Thank you very much!

30 May 2008 Giuseppe Sanfilippo

Well done, but It does not work when y is in a negative scale, i.e. y \in [-1000,0]

17 Mar 2008 Mighty Jo

Excellent,
Thank you

Comment only
21 Jul 2006 Kelvin Chou