Home > matutils > hplot.m

hplot

PURPOSE ^

hplot(bc,n,opt,lim)

SYNOPSIS ^

function hplot(bc,n,opt,lim)

DESCRIPTION ^

 hplot(bc,n,opt,lim)

 Plot a histogram as a line "paw style"

 opt = 'L' makes y axis log
 lim = lower/upper limits to plot a subset of the histogram

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function hplot(bc,n,opt,lim)
0002 % hplot(bc,n,opt,lim)
0003 %
0004 % Plot a histogram as a line "paw style"
0005 %
0006 % opt = 'L' makes y axis log
0007 % lim = lower/upper limits to plot a subset of the histogram
0008 
0009 if(~exist('opt'))
0010   opt=' ';
0011 end
0012 
0013 % Bin width (assume that bins are equal width)
0014 bw=bc(2)-bc(1);
0015 
0016 if(~exist('lim'))
0017   lim=[bc(1)-bw/2,bc(end)+bw/2];
0018 end
0019 
0020 % Use limits to remove unwanted bins
0021 ind=bc>lim(1)&bc<lim(2);
0022 bc=bc(ind);
0023 n=n(ind);
0024 
0025 % calc bin edges from centers
0026 be=bc(1)+bw/2:bw:bc(end);
0027 be2=[be;be];
0028 be2=[bc(1)-bw/2,be2(:)',bc(end)+bw/2];
0029 
0030 % Set zeros to a small value for log(y) plots
0031 n(n==0)=1e-99;
0032 
0033 n2=[n;n];
0034 n2=n2(:)';
0035 
0036 optp=opt(opt~='L'&opt~='S');
0037 
0038 if(~any(opt=='S'))
0039   plot(be2,n2,optp);
0040   xlim([be2(1),be2(end)]);
0041   
0042   m=max(n);
0043   if(any(opt=='L'))
0044     m=max(n)*2;
0045     ylim([m/1e6,m]);
0046     set(gca,'YScale','log');
0047   else
0048     ylim([0,max(n)*1.1]);
0049   end
0050 else
0051   hold on
0052   plot(be2,n2,optp);
0053   hold off
0054 end

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005