changeset 21973:894239974868

colormap: remove functionality to list and register colormaps (bug #48272) * colormap.m: remove the unused functionality which clashes with the possibility of having a colormap named list. It's also not that useful since there's no requirement to register a colormap, and therefore no guarantees that the list is complete. * autumn.m, bone.m, cool.m, copper.m, cubehelix.m, flag.m, gray.m, hot.m, hsv.m, jet.m, lines.m, ocean.m, pink.m, prism.m, rainbow.m, spring.m, summer.m, viridis.m, white.m, winter.m: remove registration to colormap().
author Carnë Draug <carandraug@octave.org>
date Mon, 20 Jun 2016 18:24:18 +0100
parents d31e0f704d0b
children 3c3995706dbe
files scripts/image/autumn.m scripts/image/bone.m scripts/image/colormap.m scripts/image/cool.m scripts/image/copper.m scripts/image/cubehelix.m scripts/image/flag.m scripts/image/gray.m scripts/image/hot.m scripts/image/hsv.m scripts/image/jet.m scripts/image/lines.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/viridis.m scripts/image/white.m scripts/image/winter.m
diffstat 21 files changed, 7 insertions(+), 115 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/image/autumn.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/autumn.m	Mon Jun 20 18:24:18 2016 +0100
@@ -29,9 +29,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "autumn");
-## PKG_DEL: colormap ("unregister", "autumn");
-
 function map = autumn (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/bone.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/bone.m	Mon Jun 20 18:24:18 2016 +0100
@@ -29,9 +29,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "bone");
-## PKG_DEL: colormap ("unregister", "bone");
-
 function map = bone (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/colormap.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/colormap.m	Mon Jun 20 18:24:18 2016 +0100
@@ -20,13 +20,10 @@
 ## -*- texinfo -*-
 ## @deftypefn  {} {@var{cmap} =} colormap ()
 ## @deftypefnx {} {@var{cmap} =} colormap (@var{map})
-## @deftypefnx {} {@var{cmap} =} colormap ("default")
-## @deftypefnx {} {@var{cmap} =} colormap ("@var{map_name}")
+## @deftypefnx {} {@var{cmap} =} colormap (@qcode{"default"})
+## @deftypefnx {} {@var{cmap} =} colormap (@var{map_name})
 ## @deftypefnx {} {@var{cmap} =} colormap (@var{hax}, @dots{})
 ## @deftypefnx {} {} colormap @var{map_name}
-## @deftypefnx {} {@var{cmaps} =} colormap ("list")
-## @deftypefnx {} {} colormap ("register", "@var{name}")
-## @deftypefnx {} {} colormap ("unregister", "@var{name}")
 ## Query or set the current colormap.
 ##
 ## With no input arguments, @code{colormap} returns the current color map.
@@ -36,11 +33,11 @@
 ## contain red, green, and blue intensities respectively.  All entries
 ## must be between 0 and 1 inclusive.  The new colormap is returned.
 ##
-## @code{colormap ("default")} restores the default colormap (the
+## @code{colormap (@qcode{"default"})} restores the default colormap (the
 ## @code{viridis} map with 64 entries).  The default colormap is returned.
 ##
-## The map may also be specified by a string, @qcode{"@var{map_name}"}, where
-## @var{map_name} is the name of a function that returns a colormap.
+## The map may also be specified by a string, @var{map_name}, which
+## is the name of a function that returns a colormap.
 ##
 ## If the first argument @var{hax} is an axes handle, then the colormap for
 ## the parent figure of @var{hax} is queried or set.
@@ -48,10 +45,6 @@
 ## For convenience, it is also possible to use this function with the
 ## command form, @code{colormap @var{map_name}}.
 ##
-## @code{colormap ("list")} returns a cell array with all of the available
-## colormaps.  The options @qcode{"register"} and @qcode{"unregister"}
-## add or remove the colormap @var{name} from this list.
-##
 ## @seealso{viridis}
 ## @end deftypefn
 
@@ -61,12 +54,9 @@
 
 function cmap = colormap (varargin)
 
-  mlock; # prevent map_list to be cleared by "clear all"
-  persistent map_list = cell ();
-
   [hax, varargin, nargin] = __plt_get_axis_arg__ ("colormap", varargin{:});
 
-  if (nargin > 2)
+  if (nargin > 1)
     print_usage ();
   endif
 
@@ -81,9 +71,6 @@
     if (ischar (map))
       if (strcmp (map, "default"))
         map = viridis (64);
-      elseif (strcmp (map, "list"))
-        cmap = map_list;
-        return;
       else
         map = feval (map);
       endif
@@ -103,23 +90,10 @@
       ## Set the new color map
       set (cf, "colormap", map);
     endif
-
-  elseif (nargin == 2)
-    opt = varargin{1};
-    name = varargin{2};
-    if (! ischar (opt) || ! any (strcmp (opt, {"register", "unregister"})))
-      print_usage ();
-    elseif (! ischar (name))
-      error ("colormap: to register/unregister a colormap, NAME must be a string");
-    elseif (strcmp (opt, "register"))
-      map_list{end+1} = name;
-    elseif (strcmp (opt, "unregister"))
-      map_list(strcmp (name, map_list)) = [];
-    endif
   endif
 
   ## Return current color map.
-  if (nargout > 0 || (nargout == 0 && nargin == 0))
+  if (nargout > 0 || nargin == 0)
     if (isempty (cf))
       cf = gcf ();
     endif
@@ -160,27 +134,6 @@
 %!   close (hf);
 %! end_unwind_protect
 
-%!test
-%! hf = figure ("visible", "off");
-%! unwind_protect
-%!   cmaplst = colormap ("list");
-%!   assert (iscell (cmaplst));
-%!   colormap ("register", "__mycmap__");
-%!   cmaplst2 = colormap ("list");
-%!   assert (numel (cmaplst2), numel (cmaplst) + 1);
-%!   assert (any (strcmp (cmaplst2, "__mycmap__")));
-%!   colormap ("unregister", "__mycmap__");
-%!   cmaplst2 = colormap ("list");
-%!   assert (numel (cmaplst2), numel (cmaplst));
-%!   assert (! any (strcmp (cmaplst2, "__mycmap__")));
-%!   ## Unregister again and verify that nothing has happened
-%!   colormap ("unregister", "__mycmap__");
-%!   cmaplst3 = colormap ("list");
-%!   assert (isequal (cmaplst2, cmaplst3));
-%! unwind_protect_cleanup
-%!   close (hf);
-%! end_unwind_protect
-
 ## Test input validation
 %!error colormap (1,2,3)
 %!error <MAP must be a real-valued N x 3> colormap ({1,2,3})
@@ -190,5 +143,4 @@
 %!error <all MAP values must be in the range> colormap ([-1 0 0])
 %!error <all MAP values must be in the range> colormap ([2 0 0])
 %!error colormap ("invalid", "name")
-%!error <NAME must be a string> colormap ("register", 1)
 
--- a/scripts/image/cool.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/cool.m	Mon Jun 20 18:24:18 2016 +0100
@@ -28,9 +28,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "cool");
-## PKG_DEL: colormap ("unregister", "cool");
-
 function map = cool (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/copper.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/copper.m	Mon Jun 20 18:24:18 2016 +0100
@@ -29,9 +29,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "copper");
-## PKG_DEL: colormap ("unregister", "copper");
-
 function map = copper (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/cubehelix.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/cubehelix.m	Mon Jun 20 18:24:18 2016 +0100
@@ -43,9 +43,6 @@
 
 ## Author: Carnë Draug <carandraug@octave.org>
 
-## PKG_ADD: colormap ("register", "cubehelix");
-## PKG_DEL: colormap ("unregister", "cubehelix");
-
 function map = cubehelix (n = rows (colormap ()), start = 0.5,
                           rots = -1.5, hue = 1, gamma = 1)
 
--- a/scripts/image/flag.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/flag.m	Mon Jun 20 18:24:18 2016 +0100
@@ -29,9 +29,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "flag");
-## PKG_DEL: colormap ("unregister", "flag");
-
 function map = flag (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/gray.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/gray.m	Mon Jun 20 18:24:18 2016 +0100
@@ -31,9 +31,6 @@
 ## Created: July 1994
 ## Adapted-By: jwe
 
-## PKG_ADD: colormap ("register", "gray");
-## PKG_DEL: colormap ("unregister", "gray");
-
 function map = gray (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/hot.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/hot.m	Mon Jun 20 18:24:18 2016 +0100
@@ -29,9 +29,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "hot");
-## PKG_DEL: colormap ("unregister", "hot");
-
 function map = hot (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/hsv.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/hsv.m	Mon Jun 20 18:24:18 2016 +0100
@@ -33,9 +33,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "hsv");
-## PKG_DEL: colormap ("unregister", "hsv");
-
 function map = hsv (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/jet.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/jet.m	Mon Jun 20 18:24:18 2016 +0100
@@ -29,9 +29,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "jet");
-## PKG_DEL: colormap ("unregister", "jet");
-
 function map = jet (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/lines.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/lines.m	Mon Jun 20 18:24:18 2016 +0100
@@ -28,9 +28,6 @@
 ## @seealso{colormap}
 ## @end deftypefn
 
-## PKG_ADD: colormap ("register", "lines");
-## PKG_DEL: colormap ("unregister", "lines");
-
 function map = lines (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/ocean.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/ocean.m	Mon Jun 20 18:24:18 2016 +0100
@@ -31,9 +31,6 @@
 ## Created: July 1994
 ## Adapted-By: jwe
 
-## PKG_ADD: colormap ("register", "ocean");
-## PKG_DEL: colormap ("unregister", "ocean");
-
 function map = ocean (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/pink.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/pink.m	Mon Jun 20 18:24:18 2016 +0100
@@ -31,9 +31,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "pink");
-## PKG_DEL: colormap ("unregister", "pink");
-
 function map = pink (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/prism.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/prism.m	Mon Jun 20 18:24:18 2016 +0100
@@ -29,9 +29,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "prism");
-## PKG_DEL: colormap ("unregister", "prism");
-
 function map = prism (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/rainbow.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/rainbow.m	Mon Jun 20 18:24:18 2016 +0100
@@ -32,9 +32,6 @@
 ## this colormap is not part of matlab, it is like the prism
 ## colormap map but with a continuous map
 
-## PKG_ADD: colormap ("register", "rainbow");
-## PKG_DEL: colormap ("unregister", "rainbow");
-
 function map = rainbow (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/spring.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/spring.m	Mon Jun 20 18:24:18 2016 +0100
@@ -28,9 +28,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "spring");
-## PKG_DEL: colormap ("unregister", "spring");
-
 function map = spring (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/summer.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/summer.m	Mon Jun 20 18:24:18 2016 +0100
@@ -29,9 +29,6 @@
 ## Author:  Kai Habel <kai.habel@gmx.de>
 ## Date:  06/03/2000
 
-## PKG_ADD: colormap ("register", "summer");
-## PKG_DEL: colormap ("unregister", "summer");
-
 function map = summer (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/viridis.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/viridis.m	Mon Jun 20 18:24:18 2016 +0100
@@ -32,9 +32,6 @@
 
 ## Author: Carlo de Falco
 
-## PKG_ADD: colormap ("register", "viridis");
-## PKG_DEL: colormap ("unregister", "viridis");
-
 ## This is a port to Octave of the default matplotlib colormap "viridis"
 ## by Eric Firing.  The original file is distributed under CC0:
 ## http://creativecommons.org/publicdomain/zero/1.0
--- a/scripts/image/white.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/white.m	Mon Jun 20 18:24:18 2016 +0100
@@ -28,9 +28,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "white");
-## PKG_DEL: colormap ("unregister", "white");
-
 function map = white (n = rows (colormap ()))
 
   if (nargin > 1)
--- a/scripts/image/winter.m	Wed Jun 22 14:05:26 2016 -0700
+++ b/scripts/image/winter.m	Mon Jun 20 18:24:18 2016 +0100
@@ -28,9 +28,6 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
-## PKG_ADD: colormap ("register", "winter");
-## PKG_DEL: colormap ("unregister", "winter");
-
 function map = winter (n = rows (colormap ()))
 
   if (nargin > 1)