Mercurial > hg > octave-lojdl
changeset 11420:466ba499eff5
Update docstrings for colormap files.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 28 Dec 2010 13:08:23 -0800 |
parents | a4822f3d1032 |
children | a451eb6f92b2 |
files | scripts/ChangeLog scripts/image/autumn.m scripts/image/bone.m scripts/image/cool.m scripts/image/copper.m scripts/image/flag.m scripts/image/gmap40.m scripts/image/gray.m scripts/image/hot.m scripts/image/hsv.m scripts/image/jet.m scripts/image/ocean.m scripts/image/pink.m scripts/image/prism.m scripts/image/rainbow.m scripts/image/spring.m scripts/image/summer.m scripts/image/white.m scripts/image/winter.m |
diffstat | 19 files changed, 252 insertions(+), 211 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,16 @@ +2010-12-28 Rik <octave@nomad.inbox5.com> + + * image/autumn.m, image/bone.m, image/cool.m, image/copper.m, + image/flag.m, image/gray.m, image/hot.m, image/hsv.m, image/jet.m, + image/ocean.m, image/pink.m, image/prism.m, image/rainbow.m, + image/spring.m, image/summer.m, image/white.m, image/winter.m: Use + same variable name for documentation and function call. Change demo + code to explicitly use colormap size. Update docstring. + + * image/gmap40.m: Use same variable name for documentation and function + call. Change demo code to use colormap size of 6 rather than 64. + Update docstring. + 2010-12-28 Ben Abbott <bpabbott@mac.com> * plot/legend.m: Add demo to legend for inline key.
--- a/scripts/image/autumn.m +++ b/scripts/image/autumn.m @@ -17,33 +17,35 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} autumn (@var{n}) -## Create color colormap. This colormap is red through orange to yellow. -## The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} autumn () +## @deftypefnx {Function File} {@var{map} =} autumn (@var{n}) +## Create color colormap. This colormap ranges from red through orange +## to yellow. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = autumn (number) +function map = autumn (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("autumn: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [1, 0, 0]; - elseif (number > 1) - r = ones (number, 1); - g = (0:number - 1)' ./ (number - 1); - b = zeros (number, 1); + elseif (n > 1) + r = ones (n, 1); + g = (0:n - 1)' ./ (n - 1); + b = zeros (n, 1); map = [r, g, b]; else map = []; @@ -55,5 +57,5 @@ %! ## Show the 'autumn' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap autumn +%! colormap (autumn (64))
--- a/scripts/image/bone.m +++ b/scripts/image/bone.m @@ -17,31 +17,33 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} bone (@var{n}) -## Create color colormap. This colormap is a gray colormap with a light -## blue tone. The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} bone () +## @deftypefnx {Function File} {@var{map} =} bone (@var{n}) +## Create color colormap. This colormap varies from black to white with +## gray-blue shades. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = bone (number) +function map = bone (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("bone: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [0, 0, 0]; - elseif (number > 1) - x = linspace (0, 1, number)'; + elseif (n > 1) + x = linspace (0, 1, n)'; r = (x < 3/4) .* (7/8 * x) + (x >= 3/4) .* (11/8 * x - 3/8); g = (x < 3/8) .* (7/8 * x)\ @@ -58,5 +60,5 @@ %! ## Show the 'bone' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap bone +%! colormap (bone (64))
--- a/scripts/image/cool.m +++ b/scripts/image/cool.m @@ -17,33 +17,34 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} cool (@var{n}) -## Create color colormap. The colormap is cyan to magenta. The argument -## @var{n} should be a scalar. If it is omitted, the length of the current -## colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} cool () +## @deftypefnx {Function File} {@var{map} =} cool (@var{n}) +## Create color colormap. The colormap varies from cyan to magenta. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = cool (number) +function map = cool (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("cool: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [0, 1, 1]; - elseif (number > 1) - r = (0:number - 1)' ./ (number - 1); + elseif (n > 1) + r = (0:n - 1)' ./ (n - 1); g = 1 - r; - b = ones (number, 1); + b = ones (n, 1); map = [r, g, b]; else map = []; @@ -55,5 +56,5 @@ %! ## Show the 'cool' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap cool +%! colormap (cool (64))
--- a/scripts/image/copper.m +++ b/scripts/image/copper.m @@ -17,31 +17,33 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} copper (@var{n}) -## Create color colormap. This colormap is black to a light copper tone. -## The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} copper () +## @deftypefnx {Function File} {@var{map} =} copper (@var{n}) +## Create color colormap. This colormap varies from black to +## a light copper tone. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = copper (number) +function map = copper (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("copper: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [0, 0, 0]; - elseif (number > 1) - x = linspace (0, 1, number)'; + elseif (n > 1) + x = linspace (0, 1, n)'; r = (x < 4/5) .* (5/4 * x) + (x >= 4/5); g = 4/5 * x; b = 1/2 * x; @@ -56,5 +58,5 @@ %! ## Show the 'copper' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap copper +%! colormap (copper (64))
--- a/scripts/image/flag.m +++ b/scripts/image/flag.m @@ -17,24 +17,23 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} flag (@var{n}) +## @deftypefn {Function File} {@var{map} =} flag () +## @deftypefnx {Function File} {@var{map} =} flag (@var{n}) ## Create color colormap. This colormap cycles through red, white, blue -## and black. The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## and black with each index change. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -## flag(number) gives a colormap consists of red, white, blue and black -## changing with each index - -function map = flag (number) +function map = flag (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("flag: argument must be a scalar"); endif else @@ -42,11 +41,11 @@ endif p = [1, 0, 0; 1, 1, 1; 0, 0, 1; 0, 0, 0]; - if (rem(number,4) == 0) - map = kron (ones (number / 4, 1), p); + if (rem(n,4) == 0) + map = kron (ones (n / 4, 1), p); else - m1 = kron (ones (fix (number / 4), 1), p); - m2 = p(1:rem (number, 4), :); + m1 = kron (ones (fix (n / 4), 1), p); + m2 = p(1:rem (n, 4), :); map = [m1; m2]; endif @@ -56,5 +55,5 @@ %! ## Show the 'flag' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap flag +%! colormap (flag (64))
--- a/scripts/image/gmap40.m +++ b/scripts/image/gmap40.m @@ -17,31 +17,32 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} gmap40 (@var{n}) -## Create a color colormap. The colormap is red, green, blue, yellow, -## magenta and cyan. These are the colors that are allowed with patch -## objects using gnuplot 4.0, and so this colormap function is specially -## designed for users of gnuplot 4.0. The argument @var{n} should be -## a scalar. If it is omitted, a length of 6 is assumed. Larger values -## of @var{n} result in a repetition of the above colors +## @deftypefn {Function File} {@var{map} =} gmap40 () +## @deftypefnx {Function File} {@var{map} =} gmap40 (@var{n}) +## Create color colormap. The colormap consists of red, green, blue, yellow, +## magenta and cyan. This colormap is specifically designed for users of +## gnuplot 4.0 where these 6 colors are the allowable ones for patch objects. +## The argument @var{n} must be a scalar. +## If unspecified, a length of 6 is assumed. Larger values +## of @var{n} result in a repetition of the above colors. ## @seealso{colormap} ## @end deftypefn -function map = gmap40 (number) +function map = gmap40 (n) if (nargin == 0) - number = 6; + n = 6; elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("gmap40: argument must be a scalar"); endif else print_usage (); endif - if (number >= 1) + if (n >= 1) map = repmat ([1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1], - ceil (number / 6), 1) (1:number, :); + ceil (n / 6), 1) (1:n, :); else map = []; endif @@ -50,7 +51,7 @@ %!demo %! ## Show the 'gmap40' colormap as an image -%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') -%! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap gmap40 +%! image (1:6, linspace (0, 1, 6), repmat (1:6, 6, 1)') +%! axis ([1, 6, 0, 1], "ticy", "xy") +%! colormap (gmap40 (6))
--- a/scripts/image/gray.m +++ b/scripts/image/gray.m @@ -18,31 +18,33 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} gray (@var{n}) -## Return a gray colormap with @var{n} entries corresponding to values from -## 0 to @var{n}-1. The argument @var{n} should be a scalar. If it is -## omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} gray () +## @deftypefnx {Function File} {@var{map} =} gray (@var{n}) +## Create gray colormap. This colormap varies from black to white with +## shades of gray. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us> ## Created: July 1994 ## Adapted-By: jwe -function map = gray (number) +function map = gray (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("gray: argument must be a scalar"); endif else print_usage (); endif - gr = [0:(number-1)]'; + gr = [0:(n-1)]'; - map = [ gr, gr, gr ] / (number - 1); + map = [ gr, gr, gr ] / (n - 1); endfunction @@ -50,5 +52,5 @@ %! ## Show the 'gray' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap gray +%! colormap (gray (64))
--- a/scripts/image/hot.m +++ b/scripts/image/hot.m @@ -17,31 +17,33 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} hot (@var{n}) -## Create color colormap. This colormap is black through dark red, red, -## orange, yellow to white. The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} hot () +## @deftypefnx {Function File} {@var{map} =} hot (@var{n}) +## Create color colormap. This colormap ranges from black through dark red, +## red, orange, yellow, to white. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = hot (number) +function map = hot (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("hot: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [0, 0, 0]; - elseif (number > 1) - x = linspace (0, 1, number)'; + elseif (n > 1) + x = linspace (0, 1, n)'; r = (x < 2/5) .* (5/2 * x) + (x >= 2/5); g = (x >= 2/5 & x < 4/5) .* (5/2 * x - 1) + (x >= 4/5); b = (x >= 4/5) .* (5*x - 4); @@ -56,5 +58,5 @@ %! ## Show the 'hot' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap hot +%! colormap (hot (64))
--- a/scripts/image/hsv.m +++ b/scripts/image/hsv.m @@ -18,36 +18,37 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} hsv (@var{n}) -## Create color colormap. This colormap is red through yellow, green, -## cyan, blue, magenta to red. It is obtained by linearly varying the -## hue through all possible values while keeping constant maximum +## Create color colormap. This colormap begins with red, changes through +## yellow, green, cyan, blue, and magenta, before returning to red. +## It is useful for displaying periodic functions. It is obtained by linearly +## varying the hue through all possible values while keeping constant maximum ## saturation and value and is equivalent to ## @code{hsv2rgb ([linspace(0,1,N)', ones(N,2)])}. ## -## The argument @var{n} should be a scalar. If it is omitted, the -## length of the current colormap or 64 is assumed. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = hsv (number) +function map = hsv (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("hsv: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [1, 0, 0]; - elseif (number > 1) - h = linspace (0, 1, number)'; - map = hsv2rgb ([h, ones(number, 1), ones(number, 1)]); + elseif (n > 1) + h = linspace (0, 1, n)'; + map = hsv2rgb ([h, ones(n, 1), ones(n, 1)]); else map = []; endif @@ -58,5 +59,5 @@ %! ## Show the 'hsv' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap hsv +%! colormap (hsv (64))
--- a/scripts/image/jet.m +++ b/scripts/image/jet.m @@ -17,31 +17,33 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} jet (@var{n}) -## Create color colormap. This colormap is dark blue through blue, cyan, -## green, yellow, red to dark red. The argument @var{n} should be a scalar. -## If it is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} jet () +## @deftypefnx {Function File} {@var{map} =} jet (@var{n}) +## Create color colormap. This colormap ranges from dark blue through blue, +## cyan, green, yellow, red, to dark red. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = jet (number) +function map = jet (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("jet: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [0, 0, 0.5]; - elseif (number > 1) - x = linspace(0, 1, number)'; + elseif (n > 1) + x = linspace(0, 1, n)'; r = (x >= 3/8 & x < 5/8) .* (4 * x - 3/2)\ + (x >= 5/8 & x < 7/8) + (x >= 7/8) .* (-4 * x + 9/2); g = (x >= 1/8 & x < 3/8) .* (4 * x - 1/2)\ @@ -59,5 +61,5 @@ %! ## Show the 'jet' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap jet +%! colormap (jet (64))
--- a/scripts/image/ocean.m +++ b/scripts/image/ocean.m @@ -18,40 +18,43 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} ocean (@var{n}) -## Create color colormap. The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} ocean () +## @deftypefnx {Function File} {@var{map} =} ocean (@var{n}) +## Create color colormap. This colormap varies from black to white with shades +## of blue. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us> ## Created: July 1994 ## Adapted-By: jwe -function map = ocean (number) +function map = ocean (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("ocean: argument must be a scalar"); endif else print_usage (); endif - cutin = fix (number/3); + cutin = fix (n/3); - dr = (number - 1) / cutin; + dr = (n - 1) / cutin; - r = prepad ([0:dr:(number-1)], number)'; + r = prepad ([0:dr:(n-1)], n)'; - dg = (number - 1) / (2 * cutin); + dg = (n - 1) / (2 * cutin); - g = prepad([0:dg:(number-1)], number)'; + g = prepad([0:dg:(n-1)], n)'; - b = [0:(number-1)]'; + b = [0:(n-1)]'; - map = [ r, g, b ] / (number - 1); + map = [ r, g, b ] / (n - 1); endfunction @@ -59,5 +62,5 @@ %! ## Show the 'ocean' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap ocean +%! colormap (ocean (64))
--- a/scripts/image/pink.m +++ b/scripts/image/pink.m @@ -17,31 +17,33 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} pink (@var{n}) -## Create color colormap. This colormap gives a sepia tone on black and -## white images. The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} pink () +## @deftypefnx {Function File} {@var{map} =} pink (@var{n}) +## Create color colormap. This colormap varies from black to white with +## shades of gray-pink. It gives a sepia tone when used on grayscale images. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = pink (number) +function map = pink (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("pink: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [0, 0, 0]; - elseif (number > 1) - x = linspace (0, 1, number)'; + elseif (n > 1) + x = linspace (0, 1, n)'; r = (x < 3/8) .* (14/9 * x) + (x >= 3/8) .* (2/3 * x + 1/3); g = (x < 3/8) .* (2/3 * x)\ + (x >= 3/8 & x < 3/4) .* (14/9 * x - 1/3)\ @@ -59,5 +61,5 @@ %! ## Show the 'pink' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap pink +%! colormap (pink (64))
--- a/scripts/image/prism.m +++ b/scripts/image/prism.m @@ -17,21 +17,23 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} prism (@var{n}) -## Create color colormap. This colormap cycles trough red, orange, yellow, -## green, blue and violet. The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} prism () +## @deftypefnx {Function File} {@var{map} =} prism (@var{n}) +## Create color colormap. This colormap cycles through red, orange, yellow, +## green, blue and violet with each index change. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = prism (number) +function map = prism (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("prism: argument must be a scalar"); endif else @@ -40,10 +42,10 @@ p = [1, 0, 0; 1, 1/2, 0; 1, 1, 0; 0, 1, 0; 0, 0, 1; 2/3, 0, 1]; - if (rem (number, 6) == 0) - map = kron(ones (fix (number / 6), 1), p); + if (rem (n, 6) == 0) + map = kron(ones (fix (n / 6), 1), p); else - map = [kron(ones (fix (number / 6), 1), p); p(1:rem (number, 6), :)]; + map = [kron(ones (fix (n / 6), 1), p); p(1:rem (n, 6), :)]; endif endfunction @@ -52,5 +54,5 @@ %! ## Show the 'prism' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap prism +%! colormap (prism (64))
--- a/scripts/image/rainbow.m +++ b/scripts/image/rainbow.m @@ -17,33 +17,36 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} rainbow (@var{n}) -## Create color colormap. This colormap is red through orange, yellow, green, -## blue to violet. The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} rainbow () +## @deftypefnx {Function File} {@var{map} =} rainbow (@var{n}) +## Create color colormap. This colormap ranges from red through orange, +## yellow, green, blue, to violet. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = rainbow (number) ## this colormap is not part of matlab, it is like the prism ## colormap map but with a continuous map +function map = rainbow (n) + if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("rainbow: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [1, 0, 0]; - elseif (number > 1) - x = linspace (0, 1, number)'; + elseif (n > 1) + x = linspace (0, 1, n)'; r = (x < 2/5) + (x >= 2/5 & x < 3/5) .* (-5 * x + 3)\ + (x >= 4/5) .* (10/3 * x - 8/3); g = (x < 2/5) .* (5/2 * x) + (x >= 2/5 & x < 3/5)\ @@ -60,5 +63,5 @@ %! ## Show the 'rainbow' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap rainbow +%! colormap (rainbow (64))
--- a/scripts/image/spring.m +++ b/scripts/image/spring.m @@ -17,32 +17,33 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} spring (@var{n}) -## Create color colormap. This colormap is magenta to yellow. -## The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} spring () +## @deftypefnx {Function File} {@var{map} =} spring (@var{n}) +## Create color colormap. This colormap varies from magenta to yellow. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = spring (number) +function map = spring (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("spring: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [1, 0, 1]; - elseif (number > 1) - r = ones (number, 1); - g = (0:number - 1)' ./ (number - 1); + elseif (n > 1) + r = ones (n, 1); + g = (0:n - 1)' ./ (n - 1); b = 1 - g; map = [r, g, b]; else @@ -55,5 +56,5 @@ %! ## Show the 'spring' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap spring +%! colormap (spring (64))
--- a/scripts/image/summer.m +++ b/scripts/image/summer.m @@ -17,33 +17,34 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} summer (@var{n}) -## Create color colormap. This colormap is green to yellow. -## The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} summer () +## @deftypefnx {Function File} {@var{map} =} summer (@var{n}) +## Create color colormap. This colormap varies from green to yellow. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> ## Date: 06/03/2000 -function map = summer (number) +function map = summer (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("summer: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [0, 0.5, 0.4]; - elseif (number > 1) - r = (0:number - 1)' ./ (number - 1); + elseif (n > 1) + r = (0:n - 1)' ./ (n - 1); g = 0.5 + r ./ 2; - b = 0.4 * ones (number, 1); + b = 0.4 * ones (n, 1); map = [r, g, b]; else @@ -56,5 +57,5 @@ %! ## Show the 'summer' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap summer +%! colormap (summer (64))
--- a/scripts/image/white.m +++ b/scripts/image/white.m @@ -17,7 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} white (@var{n}) +## @deftypefn {Function File} {@var{map} =} white () +## @deftypefnx {Function File} {@var{map} =} white (@var{n}) ## Create color colormap. This colormap is completely white. ## The argument @var{n} should be a scalar. If it ## is omitted, the length of the current colormap or 64 is assumed. @@ -26,20 +27,20 @@ ## Author: Kai Habel <kai.habel@gmx.de> -function map = white (number) +function map = white (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("white: argument must be a scalar"); endif else print_usage (); endif - if (number > 0) - map = ones (number, 3); + if (n > 0) + map = ones (n, 3); else map = []; endif @@ -50,5 +51,5 @@ %! ## Show the 'white' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap white +%! colormap (white (64))
--- a/scripts/image/winter.m +++ b/scripts/image/winter.m @@ -17,32 +17,33 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} winter (@var{n}) -## Create color colormap. This colormap is blue to green. -## The argument @var{n} should be a scalar. If it -## is omitted, the length of the current colormap or 64 is assumed. +## @deftypefn {Function File} {@var{map} =} winter () +## @deftypefnx {Function File} {@var{map} =} winter (@var{n}) +## Create color colormap. This colormap varies from blue to green. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. ## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> -function map = winter (number) +function map = winter (n) if (nargin == 0) - number = rows (colormap); + n = rows (colormap); elseif (nargin == 1) - if (! isscalar (number)) + if (! isscalar (n)) error ("winter: argument must be a scalar"); endif else print_usage (); endif - if (number == 1) + if (n == 1) map = [0, 0, 1]; - elseif (number > 1) - r = zeros (number, 1); - g = (0:number - 1)' ./ (number - 1); + elseif (n > 1) + r = zeros (n, 1); + g = (0:n - 1)' ./ (n - 1); b = 1 - g ./ 2; map = [r, g, b]; @@ -56,5 +57,5 @@ %! ## Show the 'winter' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') %! axis ([1, 64, 0, 1], "ticy", "xy") -%! colormap winter +%! colormap (winter (64))