Warning, /utils/matlab/cm_landwater.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
9e9d388224 Alis*0001 function [c] = cm_landwater(n,varargin)
0002 % [c] = cm_landwater(n)
0003 % [c] = cm_landwater(n,f)
0004 %
0005 % n - is size of color map
0006 % f is scalar fraction that should be water (default=0.5)
0007 % or vector [hmin hmax] from which f will be calculated
0008 %
0009 % e.g.
0010 % >> cm_landwater(64,caxis);
0011 %
0012 % Green-yellor land/blue water colormap
0013
0014 if nargin==1
0015 f=0.5;
0016 else
0017 f=varargin{1};
0018 end
0019
0020 if prod(size(f))==2
0021 hmin=f(1);hmax=f(2);
0022 f=-hmin/(hmax-hmin);
0023 f=max(0,f);f=min(1,f);
0024 end
0025
0026 if mod(n,2)==0
0027 nb=round(n*f(1));
0028 ng=n-nb;
0029 nw=0;
0030 else
0031 nb=floor(n*f(1));
0032 nw=1;
0033 ng=n-nb-nw;
0034 end
0035 b=bluewater(nb);
0036 g=greenland(ng);
0037 w=ones(nw,1)*[1 1 0.55];
0038
0039 c=[b' w' g']';
0040 if nargout==0
0041 colormap(c);
0042 end
0043
0044 %subplot(211)
0045 %plot((0:(n-1))/(n-1),c(:,3:-1:1))
0046 %subplot(212)
0047 %pcol([-1:.1/n:1])
0048 %axis off
0049
0050 % ----------------------------------------------------
0051 function [c] = bluewater(n)
0052 % Blue colormap
0053
0054 x=(0:n-1)'/(n-1);
0055 c=((.7-.7*x)*[1 1 0]+max(0,(1-.65*x))*[0 0 1]);
0056 c=c(end:-1:1,:);
0057 %colormap(c);
0058 % ----------------------------------------------------
0059 function [c] = greenland(n)
0060 % Green land colormap
0061
0062 x=(0:n-1)'/(n-1);
0063 r=max(0,(-.25+1.8*x));
0064 g=.4*(1+2.5*x);
0065 b=0.5*max(0,(-.25+2.0*x));
0066 i=find(r>1);
0067 r(i)=max( 1.7-1*x(i), b(i));
0068 i=find(g>1);
0069 g(i)=max( 1.5-1*x(i), b(i));
0070 c=r*[1 0 0]+g*[0 1 0]+b*[0 0 1];
0071 c=min(max(0,c),1);
0072 %colormap(c);
0073 % ----------------------------------------------------