greylevelboxplot.m

Revision 1 - 6/13/07 at 2:37 pm by e2holmes

Back to revision history for greylevelboxplot.m
This file is part of the project Plotting routines
function h=greylevelboxplot(r, xpos, greylevels, boxparms)
%greylevels are the edges of the boxes where the colors will be drawn
%xpos is where on the x axis the middle of the boxes should be

%makes a bar with grey shading for different levels
if(nargin==3) %no boxparms
        boxparms.whiswid = 0.1;
        boxparms.boxwid = 0.25;
        boxparms.boxcolor = [1 1 1];
        boxparms.lowwhis = 2.5;
        boxparms.upwhis = 97.5;
        boxparms.lowbox = 25;
        boxparms.upbox = 75;
end
    
%whiswid=.1; and boxwid=.25; are reasonable
whiswid = boxparms.whiswid;
boxwid = boxparms.boxwid;
boxcolor = boxparms.boxcolor;
lowwhis = boxparms.lowwhis;
upwhis = boxparms.upwhis;
lowbox = boxparms.lowbox;
upbox = boxparms.upbox;

n = histc(r,greylevels);
n = [n(1:(end-2)); n(end-1)+n(end)];  %histc makes the last category r == edge(end)
n = 1-n/sum(n);
    
figure(2)
plot((1-n))
pause
figure(1)

for j = 1:(length(greylevels)-1),
    botbox = greylevels(j);
    topbox = greylevels(j+1);
    boxcolor = n(j)*[1 1 1];
    h=patch([xpos-boxwid xpos+boxwid xpos+boxwid xpos-boxwid], [botbox botbox topbox topbox],boxcolor);
    set(h,'EdgeColor',boxcolor);
    hold on;
end

return
i = xpos;
   botwhis=prctile(r,lowwhis);
   topwhis=prctile(r,upwhis);
   botbox=prctile(r,lowbox);
   topbox=prctile(r,upbox);
   midbox=nanmedian(r);
   plot([i-whiswid i+whiswid],[botwhis botwhis],'-k',[i-whiswid i+whiswid],[topwhis topwhis],'-k');
   hold on;
   %patch([i-boxwid i+boxwid i+boxwid i-boxwid], [botbox botbox topbox topbox],boxcolor);
   plot([i-boxwid i+boxwid],[botbox botbox],'-k',[i-boxwid i+boxwid],[topbox topbox],'-k');
   plot([i-boxwid i+boxwid],[midbox midbox],'-k',[i-boxwid i+boxwid],[topbox topbox],'-k');
   plot([i i],[botwhis botbox],'-k',[i i],[topbox topwhis],'-k');
   plot([i-boxwid i-boxwid],[botbox topbox],'-k',[i+boxwid i+boxwid],[botbox topbox],'-k');
hold off;
%set(gca,'XLim',[0 n+1],'XTick',1:n)
Sculpin 0.2 | xhtml | problems or comments? | report bugs