File Exchange

image thumbnail

BreakAxis

version 1.0.0.0 (1.08 KB) by Michael Robbins
Produces a plot who's y-axis skips to avoid unecessary blank space.

55 Downloads

Updated 01 Jul 2003

No License

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.

Cite As

Michael Robbins (2020). BreakAxis (https://www.mathworks.com/matlabcentral/fileexchange/3668-breakaxis), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

Sachin Nair

VePu

Hello,
It gives an error in the function if I set the y-axis limit more than 50.

"Error using plot
Vectors must be the same length.
Error in BreakPlot (line 64)
h=plot(x,y2,'.');"

Does anyone know how to fix it?

Feifei Zhou

sara salehi

how one can break the Yaxis into more than two pieces

J G

Is it possible to use this for hist function?

J G

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!

Peter Lustig

Thank you very much!

Giuseppe Sanfilippo

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

Mighty Jo

Excellent,
Thank you

Kelvin Chou

Excellent! very helpful function!

Saral Gupta

very efficient, and useful. Nice work

Brett Shoelson

Nice, useful function! Would be nice to have the same for breakxaxis. (With the same patch options.)

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux