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_linestyles(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 %{ 0018 examples of properties: 0019 Color: [0 0 1] 0020 LineStyle: '-' 0021 LineWidth: 0.5000 0022 Marker: 'none' 0023 MarkerSize: 6 0024 MarkerEdgeColor: 'auto' 0025 MarkerFaceColor: 'none' 0026 %} 0027 0028 if nargin<1 || isempty(h); h=gca; end 0029 if nargin<2; property=[]; end 0030 if nargin<3; error('!'); end 0031 0032 if isempty(property); property='linewidth'; end 0033 0034 c=get(h,'children'); 0035 0036 if ~isa(values, 'cell'); 0037 values=num2cell(values,1); 0038 end 0039 0040 0041 for k=1:numel(c); 0042 set(c(numel(c)-k+1),property,values{mod(k-1,numel(c))+1}) 0043 end 0044