changeset 17703:4d8ddc44d1f2

colorbar.m: Avoid segfault in colorbar (bug #40308) * scripts/plot/draw/colorbar.m: Use low-level form of image command so that newplot is not called and axes are not switched from true plotting axes to colorbar axes object.
author Rik <rik@octave.org>
date Sat, 19 Oct 2013 17:47:45 -0700
parents 6516fc672fbb
children 7903ae3b657d
files scripts/plot/draw/colorbar.m
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/draw/colorbar.m	Sat Oct 19 17:02:50 2013 -0700
+++ b/scripts/plot/draw/colorbar.m	Sat Oct 19 17:47:45 2013 -0700
@@ -201,7 +201,9 @@
     addproperty ("axes", cax, "handle", ax);
 
     if (vertical)
-      hi = image (cax, [0,1], [cmin, cmax], [1 : clen]');
+      ## Use low-level form to avoid calling newplot which changes axes
+      hi = image (cax, "xdata", [0,1], "ydata", [cmin, cmax],
+                       "cdata", [1 : clen]');
       if (mirror)
         set (cax, "xtick", [], "xdir", "normal", "ydir", "normal",
                   "ylim", cext, "ylimmode", "manual",
@@ -212,7 +214,8 @@
                   "yaxislocation", "left", args{:});
       endif
     else
-      hi = image (cax, [cmin, cmax], [0,1], [1 : clen]);
+      hi = image (cax, "xdata", [cmin, cmax], "ydata", [0,1],
+                       "cdata", [1 : clen]);
       if (mirror)
         set (cax, "ytick", [], "xdir", "normal", "ydir", "normal",
                   "xlim", cext, "xlimmode", "manual",