function [color, style] = pickLineStyle(numLines, varargin) % % [color, style]=pickLineStyle(numLines, colorOrder, deleteColor) % % This function returns arrays of colors and line styles to be used % with plots with multiple curves. % % ** Inputs ** % numLines: Number of curves % colorOrder (optional): A two-row matrix specifying the color permutations. % This option is used to change the order of colors % to appear. colorOrder = [1,2,3;3,2,1] will move % the first color (black) to the third position and % the third color (red) to the first position. % % deleteColor (optional): An array of indices to the colors to be deleted. % Deletion is performed after the permutation. % ** Output ** % % color: numLines-by-3 matrix. Each row represents an RGB color. % % style: numLines-by-1 cell array. Each element is a string of a line % style. % %% Parse options if length(varargin) >= 1 permMat = varargin{1}; varargin(1)=[]; else permMat = [1;1]; end if length(varargin) >= 1 delMat = varargin{1}; varargin(1)=[]; else delMat = []; end if isempty(permMat) permMat = [1;1]; end %% Predefined colors colorArray=[ 0 0 0; 0 0 1.0000; 1.0000 0 0; 0 1.0000 0; 0.7600 0.6034 0.1216; 1.0000 0 1.0000; 0.0376 0.7697 0.9400; 0.9500 0.9000 0; 0.5069 0.0984 0.8200; 0.7697 0.9400 0.0376; 0.8800 0.3759 0.0704; 0.5745 0.8800 0.0704; 0.9400 0.2079 0.0376; 0.1216 0.2782 0.7600; 0.8200 0.5069 0.0984; 0.0376 0.9400 0.2079; 0.6034 0.1216 0.7600; 0.1216 0.7600 0.6034; 0.7600 0.1216 0.2782; 0 1.0000 1.0000;]; LineStyles = [repmat({'-'},[10,1]);repmat({'--'},[10,1]);repmat({'-.'},[10,1]);repmat({':'},[10,1])]; %% Perform permutation colorArray(permMat(1,:),:)=colorArray(permMat(2,:),:); %% Perform deletion colorArray(delMat,:)=[]; %% if numLines > 40 error('Number of lines exceeds the allowed limit.'); end %% nColorRepeat=floor(numLines/length(colorArray)); nColorMod=mod(numLines, length(colorArray)); %% color=[repmat(colorArray,[nColorRepeat,1]); colorArray(1:nColorMod,:)]; style=LineStyles(1:numLines);