Code covered by the BSD License  

Highlights from
interval plot

image thumbnail
from interval plot by BenoƮt Valley
plot intervals

[y]=plotinterval(varargin)
function [y]=plotinterval(varargin)
% PLOTINTERVAL interval plot
% [y]=plotinterval(I,[direc])
% Make a interval plot
% -----------------------------------------
% INPUT
% I = [start_depth end_depth index]
% direc [optional] = 'h' horizontal plot (default) or 'v' vertical plot
% -----------------------------------------
% OUPUT
% y handle on the axe
% -----------------------------------------
if nargin==1
    I=varargin{1};
    direc='h';
end
if nargin==2
    I=varargin{1};
    direc=varargin{2};
end

nd=length(I(:,1));
td=min(min(I(:,1:2)));
bd=max(max(I(:,1:2)));
vd=viredoublons(I(:,3)');
nboi=length(vd);
localindexing=[1:nboi];
color=gray(nboi+1);
color=color([nboi:-1:1],:);
if nboi==1
    color=[0 0 0];
end
y=gca;
if direc=='h'
    axis([td bd 0 1]);
    for i=1:nd
        acolor=color(find(vd==I(i,3)),:);
        rectangle('Position',[I(i,1) 0 I(i,2)-I(i,1) 1], 'FaceColor', acolor, 'EdgeColor' , acolor)
    end
end
if direc=='v'
    axis([0 1 td bd]);
    set(y,'YDir','reverse');
    for i=1:nd
        acolor=color(find(vd==I(i,3)),:);
        rectangle('Position',[0 I(i,1)   1 I(i,2)-I(i,1)], 'FaceColor', acolor, 'EdgeColor' , acolor)
    end
    set(y,'Box','on')
    set(y,'XTick',[])
end

function [y]=viredoublons(v)
% take a vector indentify and remove value appeering more than once
temp=size(v);
if temp(1)>1; v=v'; end
k=1;
while k<=length(v)
    t=find(v~=v(k));
    v=v([k t]);
    k=k+1;
end
y=sort(v);

Contact us at files@mathworks.com