nt_stylelines(h,property,values) - apply different styles to lines of plot h: handle to plot (default:gca) property: property to set (default:linewidth) values: cell array of values, one for each line Values may be a numerical matrix, in which case each row is used as a value. Styles are applied to children of h in reverse order (ie in order of plot commands). May produce unexpected results if there are childern other than plot lines.\ NoiseTools
0001 function nt_stylelines(h,property,values) 0002 %nt_stylelines(h,property,values) - apply different styles to lines of plot 0003 % 0004 % h: handle to plot (default:gca) 0005 % property: property to set (default:linewidth) 0006 % values: cell array of values, one for each line 0007 % 0008 % Values may be a numerical matrix, in which case each row is used as a 0009 % value. 0010 % 0011 % Styles are applied to children of h in reverse order (ie in order of plot 0012 % commands). May produce unexpected results if there are childern other 0013 % than plot lines.\ 0014 % 0015 % NoiseTools 0016 0017 if nargin<1 || isempty(h); h=gca; end 0018 if nargin<2; property=[]; end 0019 if nargin<3; error('!'); end 0020 0021 if isempty(property); property='linewidth'; end 0022 0023 c=get(h,'children'); 0024 0025 if ~isa(values, 'cell'); 0026 values=num2cell(values,1); 0027 end 0028 0029 0030 for k=1:numel(c); 0031 set(c(numel(c)-k+1),property,values{mod(k-1,numel(c))+1}) 0032 end 0033