forked from TASBE/TASBEFlowAnalytics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ZeroOnLog.m
43 lines (33 loc) · 1.28 KB
/
ZeroOnLog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function h=ZeroOnLog(zero,start)
% Create by Jacob Beal in 2014
% based on BreakXAxis by Julie Haas (BSD license, copyright 2004), after Michael Robbins
% Assumes an already existing plot and axes, just waiting for relabeling and marking
yrange = ylim;
t1=text((zero+start)/2,yrange(1),'//','fontsize',15);
t2=text((zero+start)/2,yrange(2),'//','fontsize',15);
% For y-axis breaks, use set(t1,'rotation',270);
% remap tick marks, and 'erase' them in the gap
xrange = xlim;
% Can't control minor range, so turn off and replace
set(gca,'XMinorTick','off')
mintick = floor(log10(start));
maxtick = floor(log10(xrange(2)));
xtick = zeros((maxtick-mintick+1)*9,1);
for i=mintick:maxtick
xtick(i*9+(1:9)) = (1:9)*10^i;
end
xtick = [zero; xtick(xtick>=start&xtick<=xrange(2))];
labels = cell(numel(xtick),1);
labels{1} = '0';
offset = 0.02;
for i=2:numel(xtick)
if log10(xtick(i))==floor(log10(xtick(i)))
label = sprintf('10^%i',log10(xtick(i)));
text(xtick(i),yrange(1),...%(yrange(1)-offset*(yrange(2)-yrange(1))),...
label,'HorizontalAlignment','center',...
'VerticalAlignment','top','rotation',0);%,'interpreter','LaTeX');
end
labels{i} = '';
end
set(gca,'XTick',xtick);
set(gca,'XTickLabel',labels);