function [cmap] = greenblack(varargin)

% function [cmap] = greenblack() % function [cmap] = greenblack(n) % % bioinformatics people often use a colormap that ranges from green % (high) to black (low). this creates just such a colormap (just % like jet or bone, that you can set for plotting, e.g. % colormap(greenblack); % % if specified, N determines how many rows to create in the % colourmap. defaults to 64 (like the other colormaps) % % modified so that the brightest green is brighter (by incrementing % redblueness a little bit too)

redratio = 0.5; blueratio = 0.2;

nRows = 64; if nargin==1 nRows = varargin{1}; if nRows < 2 error(‘nRows too small’); end end

cmap = zeros(nRows,3);

greenness = 0; redness = 0; blueness = 0; stepsize = 1/(nRows-1); for i=2:nRows greenness = greenness + stepsize; cmap(i,2) = greenness;

redness = redness + stepsize*redratio; cmap(i,[1]) = redness;

blueness = blueness + stepsize*blueratio; cmap(i,[3]) = blueness; end % i nRows

Home - Blog - Startups - Software - Research - Writing

Email me - updated 31 Dec 2012