File Exchange

BreakAxis

version 1.0 (2.76 KB) by

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

4.16667
7 Ratings

Updated

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.

sara salehi

sara salehi (view profile)

how one can break the Yaxis into more than two pieces

J G

J G (view profile)

Is it possible to use this for hist function?

J G

J G (view profile)

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

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 6.5 (R13)