⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 histoplot1.m

📁 基于Matlab的地震数据处理显示和测井数据显示于处理的小程序
💻 M
字号:
function aux=histoplot1(x,edges,varargin)% Histogram plot (1-D)%% Written by: E. R.: September 19, 2003% Last updated: January 23, 2006: Add percentile bars%%        aux=histoplot1(x,edges,varargin)% INPUT% x      column vector of samples% edges  either the vector of edges for "x"%            or the number of bins (positive integer)%            or the bin size [negative; bin size, then, is abs(edges)].%        In the second case the first bin starts at the smallest sample of%        "x" and the last bin ends at the largest sample of "x";%        in the third case the first bin starts at the smallest sample of%        "x" - bin size and the last bin ends at the largest sample %        of "x" + bin size% varargin  one or more cell arrays; the first element of each cell array is a%        keyword, the other elements are parameters. Presently, keywords are:%     'xinfo'     three-element cell array; all elements are strings; first is a %        mnemonic (for cursor tracking), second units of measurement, %        the third string is the x-axis label%        Default: {'xinfo',{'x','n/a','x'}}%     'yinfo'     three-element cell array; all elements are strings; first is a %        mnemonic (for cursor tracking), second units of measurement, %        the third string is the x-axis label%        Default: {'yinfo',{'counts','n/a','Counts'}}%     'style'   possible values are: 'line' (line representation of histogram) %                               and  'bar'  (bar representation of histogram)%        Default: {'style','line'}%     'linewidth'  only used if "style" is 'line'; width of line%        Default: {'linewidth',3}%     'percentiles'  percentile locations that should be marked by vertical lines%        No percentile lines if empty.%        Default: {'percentiles',[10,50,90]}%     'colors'    line color%        Default: {'colors','r'}%     'scale'     scale bars to represent percent%        Default: {'scale','no'}% OUTPUT% aux    structure with fields 'handle' (handle of histogram curve) and %                              'edges'  (edges of histogram bins)%                              'nn'     (histogram values; e.g.  "mystairs(edges,nn)")%                              'percentile_handles (if percentiles are plotted)global S4M%       Set defaults of input parametersparam.xinfo={'x','n/a','x'};param.yinfo=[];param.style='line';param.linewidth=3;param.colors='r';%param.display='sample count';param.percentiles=[10,50,90];param.scale='no';%       Replace defaults bu actual input paramtersparam=assign_input(param,varargin);if length(param.xinfo) == 1   param.xinfo=param.xinfo{1};endif isempty(param.yinfo)   switch param.scale      case 'yes'         param.yinfo={'counts','n/a','%'};      case 'no'         param.yinfo={'counts','n/a','Sample count'};      otherwise         error(['Unknown scale option: ',param.scale])   endelse   if length(param.yinfo) == 1      param.yinfo=param.yinfo{1};   endend        % userdata=get(gca,'UserData');if length(edges) == 1   if edges > 0      edges=linspace(min(x(:)),max(x(:))*(1+2*eps),edges+1)';   else      edges=edges4samples(min(x(:)),max(x(:)),-edges);   endend%       Compute histogramnn=histc(x(:),edges);if strcmpi(param.scale,'yes')   nn=nn*100/sum(nn);endif strcmpi(param.style,'bar')   if S4M.matlab_version < 7      hs=bar(edges,nn,'histc',param.colors);   else      hs=bar('v6',edges,nn,'histc',param.colors);      %         Get rid of asterisks along the x-axis      line_handle=findobj(gca,'Type','line');   % Use the "findobj" function to                                                % get an handle to the line object      delete(line_handle);                      % Delete the line object      clear line_handle;                        % Clear the handle                                                 % reference variable   end   lhs=length(hs);   if lhs > 1      for ii=1:length(hs)         set(hs(ii),'FaceColor',get_color(ii))      end   else      set(hs,'FaceColor',param.colors)   end   else   ntr=size(nn,2);   if ntr == 1      hs=mystairs(edges,nn(1:end-1));      set(hs,'LineWidth',param.linewidth,'Color',param.colors)        else      for ii=1:ntr         hs=mystairs(edges,nn(:,ii));         set(hs,'LineWidth',param.linewidth,'Color',get_color(ii))         hold on      end   endendgrid onxlabel(info2label(param.xinfo));ylabel(info2label(param.yinfo));bgGray  % Create gray background%    Implement cursor trackinginitiate_2d_tracking(param.xinfo,param.yinfo)%       Save handles for output (if requested)if nargout == 1   aux.handle=hs;   aux.edges=edges;   aux.nn=nn;end%       Plot percentile lines (if requested)if ~isempty(param.percentiles)   if iscell(param.percentiles)      param.percentiles=cell2mat(param.percentiles);   end   loc=percentiles_from_samples1d(x,param.percentiles);   aux2=sgrid(loc([1,3]),'v','m:',2.5);   aux1=sgrid(loc(2),'v','m--',2.5);   if nargout == 1      aux.percentile_handles=[aux1.handles;aux2.handles(:)];      aux.percentiles=param.percentiles;      aux.percentile_locations=loc;   endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -