diff scripts/image/imshow.m @ 23524:7c278572db66

Implement colormap property for axes objects (bug #48667). * graphics.cc (convert_cdata): Get colormap map data from axes ancestor to current object rather than figure ancestor. * graphics.cc (axes::properties::get_colormap): get colormap from hidden axes property __colormap__. If it is empty, get colormap from figure ancestor. * graphics.in.h (axes): Add colormap property which can be queried or set. Add hidden __colormap__ property to hold colormap data. * colormap.m: Update to allow setting colormap on axes, not just figure object. Update documentation. * imshow.m: Apply any map for indexed images to the current axes rather than current figure.
author Markus Muetzel <markus.muetzel@gmx.de>
date Tue, 23 May 2017 13:37:17 -0700
parents 092078913d54
children b208e1a7dd02
line wrap: on
line diff
--- a/scripts/image/imshow.m	Tue May 23 14:27:44 2017 -0400
+++ b/scripts/image/imshow.m	Tue May 23 13:37:17 2017 -0700
@@ -85,7 +85,7 @@
   if (ischar (im))
     [im, map] = imread (im);
     indexed = true;
-    colormap (map);
+    colormap (gca, map);
   endif
 
   nd = ndims (im);
@@ -96,7 +96,7 @@
 
   if (nd == 2)
     if (! indexed)
-      colormap (gray ());
+      colormap (gca, gray ());
     endif
   elseif (size (im, 3) == 3)
     if (ismember (class (im), {"uint8", "uint16", "double", "single"}))
@@ -117,7 +117,7 @@
       elseif (columns (arg) == 3)
         indexed = true;
         if (iscolormap (arg) && min (arg) >= 0 || max (arg) <= 1)
-          colormap (arg);
+          colormap (gca,  arg);
         else
           error ("imshow: invalid colormap MAP");
         endif
@@ -132,7 +132,7 @@
         case "colormap"
           map = varargin{narg++};
           if (iscolormap (map) && min (map) >= 0 || max (map) <= 1)
-            colormap (map);
+            colormap (gca, map);
           else
             error ("imshow: invalid colormap");
           endif