octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Colorbar function


From: David Bateman
Subject: Colorbar function
Date: Thu, 22 Nov 2007 01:15:20 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Attached is a patch that adds the colorbar function. It doesn't do it
matlab's way and suffers from a few issues to do with gnuplot's buggy
colorbars. Matlab adds a colorbar as a separate axis to the plot. This
means that there must be an exchange of information between the two set
of axis, and this needs listener functions.

However, if the colorbar is made a property of the current axis, then no
sharing of data is needed. However, this means that some of the addition
 matlab functionality by using "set" on the axes handle of the colorbar
is not available.

As for the gnuplot issues these are

* For colorbar positions inside the border of the plot, gnuplot appears
to plot the colorbar in the background of the plot. Therefore it is
often hidden by the plot itself. It would make more sense to always have
it in the foreground.. For example try

contour(peak)
colorbar("east")

* gnuplot gives no manner to place the colorbar directly inside/outside,
etc in the same manner as the key. Furthermore for splot, only the
screen coords can be used to place the colorbar. Therefore, I had to
derive an empirical formula to position the colorbar correctly and to
equaly do so for subplots. Therefore, don't expect the colorbar to
always exactly line up with the plot itself..

* Gnuplots postscript driver gets the bounding box wrong when there is a
colorbar.. The colorbar is there, just outside the bounding box, so a
little hand editing, or negative cropping will get the colorbar back

D.
*** ./scripts/plot/colorbar.m.orig21    2007-11-21 11:16:09.694890190 +0100
--- ./scripts/plot/colorbar.m   2007-11-22 01:11:25.753950362 +0100
***************
*** 0 ****
--- 1,149 ----
+ ## Copyright (C) 2007 David Bateman
+ ##
+ ## This file is part of Octave.
+ ##
+ ## Octave is free software; you can redistribute it and/or modify it
+ ## under the terms of the GNU General Public License as published by
+ ## the Free Software Foundation; either version 3 of the License, or (at
+ ## your option) any later version.
+ ##
+ ## Octave is distributed in the hope that it will be useful, but
+ ## WITHOUT ANY WARRANTY; without even the implied warranty of
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ ## General Public License for more details.
+ ##
+ ## You should have received a copy of the GNU General Public License
+ ## along with Octave; see the file COPYING.  If not, see
+ ## <http://www.gnu.org/licenses/>.
+ 
+ ## -*- texinfo -*-
+ ## @deftypefn {Function File} {} colorbar (@var{s})
+ ## @deftypefnx {Function File} {} colorbar ('peer', @var{h}, @dots{})
+ ## Adds a colorbar to the current axes. Valid values for @var{s} are
+ ##
+ ## @table @asis
+ ## @item 'EastOutside'
+ ## Place the colorbar outside the plot to the right. This is the default.
+ ## @item 'East'
+ ## Place the colorbar inside the plot to the right.
+ ## @item 'WestOutside'
+ ## Place the colorbar outside the plot to the left.
+ ## @item 'West'
+ ## Place the colorbar inside the plot to the left.
+ ## @item 'NorthOutside'
+ ## Place the colorbar above the plot.
+ ## @item 'North'
+ ## Place the colorbar at the top of the plot.
+ ## @item 'SouthOutside'
+ ## Place the colorbar under the plot.
+ ## @item 'South'
+ ## Place the colorbar at the bottom of the plot.
+ ## @item 'Off', 'None'
+ ## Remove any existing colorbar from the plot.
+ ## @end table
+ ##
+ ## If the argument 'peer' is given, then the following argument is treated a
+ ## the axes handle on which to add the colorbar.
+ ## @end deftypefn
+ 
+ 
+ ## PKG_ADD: mark_as_command colorbar
+ 
+ function colorbar (varargin)
+   
+   if (nargin > 0 && strcmpi(varargin{1}, "peer"))
+     if (nargin > 1)
+       ax = varargin{2};
+       if (!isscalar (ax) || !ishandle (ax) || 
+         strcmp (get (ax, "type"), "axes"))
+       error ("colorbar: expecting an axes handle following 'peer'");
+       endif
+     else
+       error ("colorbar: misisng axes handle after 'peer'");
+     endif
+   else
+     ax = gca ();
+   endif
+ 
+   pos = "eastoutside";
+   for i = 1 : length (varargin)
+     arg = varargin {i};
+     if (length(arg) < 1)
+       pos = "eastoutside";
+     elseif (ischar (arg))
+       arg = tolower (arg);
+       if (strcmp (arg, "off") || strcmp (arg, "none"))
+       pos = "none";
+       elseif (strcmp (arg, "north") || strcmp (arg, "south") ||
+             strcmp (arg, "east") || strcmp (arg, "west") ||
+             strcmp (arg, "northoutside") || strcmp (arg, "southoutside") ||
+             strcmp (arg, "eastoutside") || strcmp (arg, "westoutside"))
+       pos = arg;
+       else
+       error ("colorbar: unrecognized position argument");
+       endif
+     else
+       error ("colorbar: expecting string arguments");
+     endif
+   endfor
+ 
+   set (ax, "__colorbar__", pos);
+ endfunction
+ 
+ 
+ %!demo
+ %! hold off;
+ %! close all;
+ %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); 
+ %! imagesc(x)
+ %! colorbar();
+ 
+ %!demo
+ %! hold off;
+ %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); 
+ %! imagesc(x)
+ %! colorbar("westoutside");
+ 
+ %!demo
+ %! hold off;
+ %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); 
+ %! imagesc(x)
+ %! colorbar("northoutside");
+ 
+ %!demo
+ %! hold off;
+ %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); 
+ %! imagesc(x)
+ %! colorbar("southoutside");
+ 
+ %!demo
+ %! hold off;
+ %! subplot(2,2,1)
+ %! contour(peaks())
+ %! colorbar("east");
+ %! subplot(2,2,2)
+ %! contour(peaks())
+ %! colorbar("west");
+ %! subplot(2,2,3)
+ %! contour(peaks())
+ %! colorbar("north");
+ %! subplot(2,2,4)
+ %! contour(peaks())
+ %! colorbar("south");
+ 
+ %!demo
+ %! hold off;
+ %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); 
+ %! subplot(2,2,1)
+ %! imagesc(x)
+ %! colorbar();
+ %! subplot(2,2,2)
+ %! imagesc(x)
+ %! colorbar("westoutside");
+ %! subplot(2,2,3)
+ %! imagesc(x)
+ %! colorbar("northoutside");
+ %! subplot(2,2,4)
+ %! imagesc(x)
+ %! colorbar("southoutside");
+ 
*** ./scripts/plot/__go_draw_axes__.m.orig21    2007-11-21 11:16:25.543080897 
+0100
--- ./scripts/plot/__go_draw_axes__.m   2007-11-22 00:20:22.357477148 +0100
***************
*** 32,50 ****
        = compare_versions (__gnuplot_version__ (), "4.0", ">");
  
      ## Set axis properties here?
! 
      if (! isempty (axis_obj.outerposition))
        pos = axis_obj.outerposition;
-       fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
-       fprintf (plot_stream, "set size %.15g, %.15g;\n", pos(3), pos(4));
      endif
  
      if (! isempty (axis_obj.position))
        pos = axis_obj.position;
-       fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
-       fprintf (plot_stream, "set size %.15g, %.15g;\n", pos(3), pos(4));
      endif
  
      if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
        r = axis_obj.dataaspectratio;
        fprintf (plot_stream, "set size ratio %.15g;\n", -r(2)/r(1));
--- 32,54 ----
        = compare_versions (__gnuplot_version__ (), "4.0", ">");
  
      ## Set axis properties here?
!     pos = [0,0,1,1];
      if (! isempty (axis_obj.outerposition))
        pos = axis_obj.outerposition;
      endif
  
      if (! isempty (axis_obj.position))
        pos = axis_obj.position;
      endif
  
+     if (! strcmp (axis_obj.__colorbar__, "none"))
+       [pos, cbox_orient, cbox_size, cbox_origin, cbox_mirror] = ...
+         gnuplot_postion_colorbox (pos, axis_obj.__colorbar__);
+     endif
+ 
+     fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
+     fprintf (plot_stream, "set size %.15g, %.15g;\n", pos(3), pos(4));
+ 
      if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
        r = axis_obj.dataaspectratio;
        fprintf (plot_stream, "set size ratio %.15g;\n", -r(2)/r(1));
***************
*** 52,57 ****
--- 56,62 ----
        fputs (plot_stream, "set size noratio;\n");
      endif
  
+     fputs (plot_stream, "set pm3d;\n");
      fputs (plot_stream, "unset label;\n");
  
      if (! isempty (axis_obj.title))
***************
*** 215,220 ****
--- 220,242 ----
      xmax = ymax = zmax = cmax = -Inf;
      xmin = ymin = zmin = cmin = Inf;
  
+     ## This has to be done here as some of the code below depends on the
+     ## final clim
+     if (cautoscale)
+       for i = 1:length (kids)
+       obj = get (kids(i));
+       if (isfield (obj, "cdata"))
+         [cmin, cmax, cminp] = get_data_limits (cmin, cmax, cminp, 
+                                                obj.cdata(:));
+       endif
+       endfor
+       clim = [cmin, cmax];
+     else
+       clim = axis_obj.clim;
+     endif
+     
+ 
+ 
      [view_cmd, view_fcn, view_zoom] = image_viewer ();
      use_gnuplot_for_images = (ischar (view_fcn)
                              && strcmp (view_fcn, "gnuplot_internal"));
***************
*** 237,243 ****
          endif
  
          img_data = obj.cdata;
-         img_colormap = parent_figure_obj.colormap;
          img_xdata = obj.xdata;
          img_ydata = obj.ydata;
  
--- 259,264 ----
***************
*** 284,304 ****
              imagetype = "rgbimage";
            else
              data{data_idx} = img_data(:);
-             if (cautoscale)
-               [cmin, cmax, cminp] = get_data_limits (cmin, cmax, cminp, 
-                                                      data{data_idx});
-             endif
              format = "1";
              imagetype = "image";
- 
-             palette_size = rows (img_colormap);
-             fprintf (plot_stream,
-                      "set palette positive color model RGB maxcolors %i;\n",
-                      palette_size);
-             fprintf (plot_stream,
-                      "set palette file \"-\" binary record=%d using 
1:2:3:4;\n",
-                      palette_size);
-             fwrite (plot_stream, [1:palette_size; img_colormap'], "float32");
            endif
  
            titlespec{data_idx} = "title \"\"";
--- 305,312 ----
***************
*** 444,457 ****
  
         case "patch"
           cmap = parent_figure_obj.colormap;
-        clim = axis_obj.clim;
         [nr, nc] = size (obj.xdata);
  
         if (! isempty (obj.cdata))
           cdat = obj.cdata;
-          if (cautoscale)
-            [cmin, cmax, cminp] = get_data_limits (cmin, cmax, cminp, cdat);
-          endif
         else
           cdat = [];
         endif
--- 452,461 ----
***************
*** 823,832 ****
              tz = zdat(:);
              [zmin, zmax, zminp] = get_data_limits (zmin, zmax, zminp, tz);
            endif
-           if (cautoscale)
-             tc = cdat(:);
-             [cmin, cmax, cminp] = get_data_limits (cmin, cmax, cminp, tc);
-           endif
  
            err = false;
              if (! size_equal(zdat, cdat))
--- 827,832 ----
***************
*** 866,872 ****
              data{data_idx} = zz.';
            endif
            usingclause{data_idx} = "using ($1):($2):($3):($4)";
-           withclause{data_idx} = "with line palette";
  
            fputs (plot_stream, "unset parametric;\n");
            fputs (plot_stream, "set style data lines;\n");
--- 866,871 ----
***************
*** 876,882 ****
            ## Interpolation does not work for flat surfaces (e.g. pcolor)
              ## and color mapping --> currently set empty.
              interp_str = "";
-             surf_colormap = parent_figure_obj.colormap;
              flat_interp_face = (strncmp (obj.facecolor, "flat", 4)
                                || strncmp (obj.facecolor, "interp", 6));
              flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4)
--- 875,880 ----
***************
*** 885,892 ****
            facecolor_none_or_white = (strncmp (obj.facecolor, "none", 4)
                                       || (isnumeric (obj.facecolor)
                                           && all (obj.facecolor == 1)));
-             palette_data = [];
- 
            if (strncmp (obj.facecolor, "none", 4))
              if (isnan (hidden_removal))
                hidden_removal = false;
--- 883,888 ----
***************
*** 897,912 ****
  
              if (flat_interp_face
                || (flat_interp_edge && facecolor_none_or_white))
!               palette_data = [1:rows(surf_colormap); surf_colormap'];
!           elseif (isnumeric (obj.facecolor))
!               palette_data = [1:2; [obj.facecolor; obj.facecolor]'];
              endif
  
-           if (facecolor_none_or_white && isnumeric (obj.edgecolor))
-               palette_data = [1:2; [obj.edgecolor; obj.edgecolor]'];
-             endif
- 
- 
            if (have_newer_gnuplot)
              dord = "depthorder";
            else
--- 893,901 ----
  
              if (flat_interp_face
                || (flat_interp_edge && facecolor_none_or_white))
!             withclause{data_idx} = "with line palette";
              endif
  
            if (have_newer_gnuplot)
              dord = "depthorder";
            else
***************
*** 914,920 ****
            endif
  
            if (facecolor_none_or_white)
!             ## Do nothing.
              elseif (flat_interp_face && strncmp (obj.edgecolor, "flat", 4))
                fprintf (plot_stream, "set pm3d at s %s %s;\n", 
                       interp_str, dord);
--- 903,910 ----
            endif
  
            if (facecolor_none_or_white)
!             ## Ensure faces aren't drawn
!             fprintf (plot_stream, "unset pm3d;\n");
              elseif (flat_interp_face && strncmp (obj.edgecolor, "flat", 4))
                fprintf (plot_stream, "set pm3d at s %s %s;\n", 
                       interp_str, dord);
***************
*** 960,991 ****
                endif
                endif
              endif
- 
-           if (have_newer_gnuplot)
-               if (length(palette_data) > 0)
-                 fprintf (plot_stream,
-                        "set palette positive color model RGB maxcolors %i;\n",
-                        columns(palette_data));
-               fprintf (plot_stream,
-                        "set palette file \"-\" binary record=%d using 
1:2:3:4;\n",
-                        columns(palette_data));
-               fwrite (plot_stream, palette_data, "float32");
-               endif
-           else
-             fputs (plot_stream, "set palette defined (");
-             for i = 1: columns(palette_data)
-               col = floor(palette_data(2:end,i).' * 255);
-               if (i == 1)
-                 fputs (plot_stream, sprintf("%d \"#%02X%02X%02X\"", i - 1, 
-                                             col(1), col(2), col(3)));
-               else
-                 fputs (plot_stream, sprintf(", %d \"#%02X%02X%02X\"", i - 1, 
-                                             col(1), col(2), col(3)));
-               endif
-             endfor
-             fputs (plot_stream, ");\n");
-           endif
-           fputs (plot_stream, "unset colorbox;\n");
          endif
  
        case "text"
--- 950,955 ----
***************
*** 1110,1119 ****
      endif
  
      if (cautoscale && have_data)
-       clim = [cmin, cmax];
        set (h, "clim", clim, "climmode", "auto");
-     else
-       clim = axis_obj.clim;
      endif
      if (! any (isinf (clim)))
        fprintf (plot_stream, "set cbrange [%g:%g];\n", clim);
--- 1074,1080 ----
***************
*** 1206,1211 ****
--- 1167,1209 ----
        endfor
      endif
  
+     cmap = parent_figure_obj.colormap;    
+     cmap_sz = rows(cmap);
+     if (length(cmap) > 0)
+       if (have_newer_gnuplot)
+         fprintf (plot_stream,
+                "set palette positive color model RGB maxcolors %i;\n",
+                cmap_sz);
+       fprintf (plot_stream,
+                "set palette file \"-\" binary record=%d using 1:2:3:4;\n",
+                cmap_sz);
+       fwrite (plot_stream, [1:cmap_sz; cmap.'], "float32");
+       else
+       fputs (plot_stream, "set palette defined (");
+       for i = 1: cmap_sz
+         col = floor(cmap(i, :) * 255);
+           if (i == 1)
+           fputs (plot_stream, sprintf("%d \"#%02X%02X%02X\"", i - 1, 
+                                       col(1), col(2), col(3)));
+         else
+           fputs (plot_stream, sprintf(", %d \"#%02X%02X%02X\"", i - 1, 
+                                       col(1), col(2), col(3)));
+         endif
+       endfor
+       fputs (plot_stream, ");\n");
+       endif
+     endif
+           
+     if (strcmp (axis_obj.__colorbar__, "none"))
+       fputs (plot_stream, "unset colorbox;\n");
+     else
+       ## FIXME If cbox_mirror is true we want to invert the tic labels
+       ## but gnuplot doesn't allow that
+       fputs (plot_stream, 
+            sprintf ("set colorbox %s user origin %f,%f size %f,%f;\n",
+                     cbox_orient, cbox_origin, cbox_size));
+     endif
+ 
      if (have_data)
        if (nd == 2)
        plot_cmd = "plot";
***************
*** 1945,1947 ****
--- 1943,2014 ----
    sym.rceil  = '{/Symbol \371}';
    sym.int = '{/Symbol \362}';
  endfunction
+ 
+ function [pos, orient, sz, origin, mirr] = gnuplot_postion_colorbox (pos, 
cbox)
+   ## This is an emprically derived function that 
+ 
+   if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5))
+     scl = pos([2,4]);
+   else
+     scl = pos([1,3]);
+   endif
+ 
+   if (length(cbox) > 7 && strncmp (cbox(end-6:end), "outside", 7))
+     scl(2) -= 0.2 * scl(2);
+     if (strncmp (cbox, "west", 4) || strncmp (cbox, "south", 5))
+       scl(1) += 0.2 * scl(2);
+     endif
+   endif
+ 
+   switch (cbox)
+     case "northoutside"
+       sz = pos(3:4) - 0.08;
+       origin = [0.05, 0.06] + [0.00, 0.88] .* sz + pos(1:2);
+       mirr = true;
+       orient = "horizontal";
+     case "north"
+       sz = pos(3:4) - 0.16;
+       origin = [0.09, 0.09] + [0.00, 0.94] .* sz + pos(1:2);
+       mirr = false;
+       orient = "horizontal";
+     case "southoutside"
+       sz = pos(3:4) - 0.08;
+       origin = [0.05, 0.06] + [0.00, 0.00] .* sz + pos(1:2);
+       mirr = false;
+       orient = "horizontal";
+     case "south"
+       sz = pos(3:4) - 0.16;
+       origin = [0.08, 0.09] + [0.03, 0.05] .* sz + pos(1:2);
+       mirr = true;
+       orient = "horizontal";
+     case "eastoutside"
+       sz = pos(3:4) - 0.08;
+       origin = [0.00, 0.06] + [0.94, 0.00] .* sz + pos(1:2);
+       mirr = false;
+       orient = "vertical";
+     case "east"
+       sz = pos(3:4) - 0.16;
+       origin = [0.09, 0.10] + [0.91, 0.01] .* sz + pos(1:2);
+       mirr = true;
+       orient = "vertical";
+     case "westoutside"
+       sz = pos(3:4) - 0.08;
+       origin = [0.00, 0.06] + [0.06, 0.00] .* sz + pos(1:2);
+       mirr = true;
+       orient = "vertical";
+     case "west"
+       sz = pos(3:4) - 0.16;
+       origin = [0.06, 0.09] + [0.04, 0.03] .* sz + pos(1:2);
+       mirr = false;
+       orient = "vertical";
+   endswitch
+ 
+   if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5))
+     sz = sz .* [1, 0.07];
+     pos([2,4]) = scl;
+   else
+     sz = sz .* [0.07, 1];
+     pos([1,3]) = scl;
+   endif
+ 
+ endfunction
*** ./scripts/plot/Makefile.in.orig21   2007-11-21 11:16:16.682533405 +0100
--- ./scripts/plot/Makefile.in  2007-11-21 11:21:03.769824388 +0100
***************
*** 75,80 ****
--- 75,81 ----
    clf.m \
    close.m \
    closereq.m \
+   colorbar.m \
    contour3.m \
    contour.m \
    contourc.m \
*** ./scripts/plot/__contour__.m.orig21 2007-11-21 18:29:17.882187122 +0100
--- ./scripts/plot/__contour__.m        2007-11-21 18:30:04.669831579 +0100
***************
*** 38,52 ****
      endif
    endif
  
-   clim = get (ax, "clim");
- 
    [c, lev] = contourc (varargin{3:end});
  
    ## Decode contourc output format.
    i1 = 1;
    h = [];
-   maxlev = max (lev);
-   minlev = min (lev);
    while (i1 < length (c))
      clev = c(1,i1);
      clen = c(2,i1);
--- 38,48 ----
***************
*** 57,78 ****
        p = [c(:, i1+1:i1+clen), NaN(2, 1)];
      endif
  
-     if (maxlev == minlev)
-       lev = clim(1);
-     else
-       lev = (clev - minlev) * (clim(2) - clim(1)) / ...
-         (maxlev - minlev) + clim(1);
-     endif
- 
      if (isnan (z))
        h = [h; patch(ax, p(1,:), p(2,:), "facecolor", "none", 
!                   "edgecolor", "flat", "cdata", lev)];
      elseif (!ischar(z))
        h = [h; patch(ax, p(1,:), p(2,:), z * ones (1, columns (p)), 
"facecolor",
!                   "none", "edgecolor", "flat", "cdata", lev)];
      else
        h = [h; patch(ax, p(1,:), p(2,:), clev * ones (1, columns (p)),
!                   "facecolor", "none", "edgecolor", "flat", "cdata", lev)];
      endif
      i1 += clen+1;
    endwhile
--- 53,67 ----
        p = [c(:, i1+1:i1+clen), NaN(2, 1)];
      endif
  
      if (isnan (z))
        h = [h; patch(ax, p(1,:), p(2,:), "facecolor", "none", 
!                   "edgecolor", "flat", "cdata", clev)];
      elseif (!ischar(z))
        h = [h; patch(ax, p(1,:), p(2,:), z * ones (1, columns (p)), 
"facecolor",
!                   "none", "edgecolor", "flat", "cdata", clev)];
      else
        h = [h; patch(ax, p(1,:), p(2,:), clev * ones (1, columns (p)),
!                   "facecolor", "none", "edgecolor", "flat", "cdata", clev)];
      endif
      i1 += clen+1;
    endwhile
*** ./src/graphics.cc.orig21    2007-11-21 10:59:07.477302712 +0100
--- ./src/graphics.cc   2007-11-21 11:07:04.233114533 +0100
***************
*** 1112,1118 ****
      view (),
      visible ("on"),
      nextplot ("replace"),
!     outerposition ()
  {
    Matrix tlim (1, 2, 0.0);
    tlim(1) = 1;
--- 1112,1119 ----
      view (),
      visible ("on"),
      nextplot ("replace"),
!     outerposition (),
!     __colorbar__ (radio_values 
("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside"))
  {
    Matrix tlim (1, 2, 0.0);
    tlim(1) = 1;
***************
*** 1313,1318 ****
--- 1314,1321 ----
      set_nextplot (val);
    else if (name.compare ("outerposition"))
      set_outerposition (val);
+   else if (name.compare ("__colorbar__"))
+     set___colorbar__ (val);
    else
      {
        modified = false;
***************
*** 1399,1404 ****
--- 1402,1409 ----
        outerposition = touterposition;
      }
  
+   __colorbar__  = radio_property (radio_values 
("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside"));
+ 
    delete_children ();
  
    children = Matrix ();
***************
*** 1502,1507 ****
--- 1507,1513 ----
    m.assign ("visible", visible);
    m.assign ("nextplot", nextplot);
    m.assign ("outerposition", outerposition);
+   m.assign ("__colorbar__", __colorbar__);
  
    return m;
  }
***************
*** 1621,1626 ****
--- 1627,1634 ----
      retval = nextplot;
    else if (name.compare ("outerposition"))
      retval = outerposition;
+   else if (name.compare ("__colorbar__"))
+     retval = __colorbar__;
    else
      warning ("get: invalid property `%s'", name.c_str ());
  
***************
*** 1727,1732 ****
--- 1735,1741 ----
    touterposition(3) = 1;
  
    m["outerposition"] = touterposition;
+   m["__colorbar__"] = radio_property (radio_values 
("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside"));
  
    return m;
  }
*** ./src/graphics.h.in.orig21  2007-11-21 10:59:16.297854721 +0100
--- ./src/graphics.h.in 2007-11-21 11:00:13.315951339 +0100
***************
*** 1199,1205 ****
        octave_value visible
        octave_value nextplot
        octave_value outerposition
!     END_PROPERTIES
  
      static std::string go_name;
    };
--- 1199,1206 ----
        octave_value visible
        octave_value nextplot
        octave_value outerposition
!       radio_property __colorbar__ a
!    END_PROPERTIES
  
      static std::string go_name;
    };
2007-11-20  David Bateman  <address@hidden>

        * plot/colorbar.m: New function.
        * plot/Makefile.in (SOURCES): Add it to the sources.
        * plot/__go_draw_axes__.m: Calculate the colorbar position,
        precalculate the clim, set pm3d except for mesh.
        * plot/__contour__.m: Don't scale the contours to clim, but rather
        save the real values so that colorbar corresponds to the contour
        levels.

2007-11-20  David Bateman  <address@hidden>

        * graphics.cc (class axes): Add __colorbar__ property.
        * graphics.h.in (class axes): ditto.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]