make cyclic color map made by two colors cmap = cmap_cycle(color_name,Ncycle,Nrepeat) base_color : [N x 3] color map matrix bg_color : [1 x 3] RGB color corresponding to background color Ncycle : cycle length if N < Ncycle, bg_color is added (Ncycle-N) times if N >= Ncycle, base_color is trancated as [Ncycle x 3] Nrepeat : repetition number of cycle cmap : [(Ncycle*Nrepeat) x 3] color map matrix Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function cmap = cmap_cycle(base_color,bg_color,Ncycle,Nrepeat) 0002 % make cyclic color map made by two colors 0003 % cmap = cmap_cycle(color_name,Ncycle,Nrepeat) 0004 % base_color : [N x 3] color map matrix 0005 % bg_color : [1 x 3] RGB color corresponding to background color 0006 % Ncycle : cycle length 0007 % if N < Ncycle, bg_color is added (Ncycle-N) times 0008 % if N >= Ncycle, base_color is trancated as [Ncycle x 3] 0009 % Nrepeat : repetition number of cycle 0010 % cmap : [(Ncycle*Nrepeat) x 3] color map matrix 0011 % 0012 % Copyright (C) 2011, ATR All Rights Reserved. 0013 % License : New BSD License(see VBMEG_LICENSE.txt) 0014 0015 [N ,Nc]= size(base_color); 0016 0017 if Nc ~= 3, error('Color matrix must be N x 3'); end; 0018 0019 Nc = length(bg_color); 0020 0021 if Nc ~= 3, error('Color must be 1 x 3'); end; 0022 0023 if Ncycle > N, 0024 cmap = repmat(bg_color(:)', [Ncycle 1]); 0025 ix = 1:N; 0026 cmap(ix + (Ncycle-N), :) = base_color; 0027 else 0028 cmap = base_color((N-Ncycle+1):N,:); 0029 end 0030 0031 cmap = repmat(cmap,[Nrepeat 1]);