changeset 9896:1aeb39118764

convert some plot functions to subfunctions or make some them private
author John W. Eaton <jwe@octave.org>
date Tue, 01 Dec 2009 15:59:43 -0500
parents 5a4f8d52bb0e
children 4bf50a7d533b
files scripts/ChangeLog scripts/plot/__actual_axis_position__.m scripts/plot/__area__.m scripts/plot/__axes_limits__.m scripts/plot/__axis_label__.m scripts/plot/__bar__.m scripts/plot/__bars__.m scripts/plot/__clabel__.m scripts/plot/__contour__.m scripts/plot/__default_plot_options__.m scripts/plot/__errcomm__.m scripts/plot/__errplot__.m scripts/plot/__ezplot__.m scripts/plot/__interp_cube__.m scripts/plot/__line__.m scripts/plot/__patch__.m scripts/plot/__plr1__.m scripts/plot/__plr2__.m scripts/plot/__plt1__.m scripts/plot/__plt2__.m scripts/plot/__plt2mm__.m scripts/plot/__plt2mv__.m scripts/plot/__plt2ss__.m scripts/plot/__plt2sv__.m scripts/plot/__plt2vm__.m scripts/plot/__plt2vs__.m scripts/plot/__plt2vv__.m scripts/plot/__plt__.m scripts/plot/__pltopt1__.m scripts/plot/__pltopt__.m scripts/plot/__quiver__.m scripts/plot/__scatter__.m scripts/plot/__stem__.m scripts/plot/area.m scripts/plot/module.mk scripts/plot/polar.m scripts/plot/private/__actual_axis_position__.m scripts/plot/private/__axes_limits__.m scripts/plot/private/__axis_label__.m scripts/plot/private/__bar__.m scripts/plot/private/__clabel__.m scripts/plot/private/__contour__.m scripts/plot/private/__default_plot_options__.m scripts/plot/private/__errcomm__.m scripts/plot/private/__errplot__.m scripts/plot/private/__ezplot__.m scripts/plot/private/__interp_cube__.m scripts/plot/private/__line__.m scripts/plot/private/__patch__.m scripts/plot/private/__plt__.m scripts/plot/private/__pltopt__.m scripts/plot/private/__quiver__.m scripts/plot/private/__scatter__.m scripts/plot/private/__stem__.m
diffstat 54 files changed, 4847 insertions(+), 5165 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Tue Dec 01 10:38:27 2009 -0800
+++ b/scripts/ChangeLog	Tue Dec 01 15:59:43 2009 -0500
@@ -1,3 +1,40 @@
+2009-12-01  John W. Eaton  <jwe@octave.org>
+
+	* plot/private/__axes_limits__.m:
+	* plot/private/__axis_label__.m:
+	* plot/private/__bar__.m:
+	* plot/private/__clabel__.m:
+	* plot/private/__contour__.m:
+	* plot/private/__errcomm__.m:
+	* plot/private/__errplot__.m:
+	* plot/private/__ezplot__.m:
+	* plot/private/__line__.m:
+	* plot/private/__patch__.m:
+	* plot/private/__plt__.m:
+	* plot/private/__pltopt__.m:
+	* plot/private/__quiver__.m: Rename from plot/__quiver__.m
+	* plot/private/__scatter__.m:
+	* plot/private/__stem__.m:
+	* plot/private/__interp_cube__.m:
+	* plot/private/__add_datasource__.m:
+	* plot/private/__actual_axis_position__.m
+	* plot/private/__default_plot_options__.m
+
+	* plot/__pltopt1__.m: Now a subfunction of plot/__pltopt__.m.
+
+	* plot/__bars__.m: Now a subfunction of plot/__bar__.m.
+	* plot/__bar__.m (bars): Rename from __bars__.
+	(__bar__): Call bars insteaad of __bars__.
+
+	* plot/__area__.m: Now a subfunction of plot/area.m.
+
+	* plot/__plr1__.m, plot/__plr2__.m: Now subfunctions of polar.m.
+
+	* plot/__plt1__.m, plot/__plt2__.m, plot/__plt2mm__.m,
+	plot/__plt2mv__.m, plot/__plt2ss__.m, plot/__plt2sv__.m,
+	plot/__plt2vm__.m, plot/__plt2vs__.m, plot/__plt2vv__.m:
+	Now subfunctions of __plt__.m.
+
 2009-11-30  John W. Eaton  <jwe@octave.org>
 
 	* mkdoc: Handle classes in function names.
--- a/scripts/plot/__actual_axis_position__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-## Copyright (C) 2009 Ben Abbott
-##
-## 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} {} __actual_axis_position__ (@var{h})
-## @deftypefnx {Function File} {} __actual_axis_position__ (@var{axis_struct})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: Ben Abbott
-
-function pos = __actual_axis_position__ (axis_obj)
-  if (ishandle (axis_obj))
-    axis_obj = get (axis_obj);
-  endif
-
-  ## When using {rltb}margin, Gnuplot does not handle the specified
-  ## aspect ratio properly, so handle it here.
-  if (__calc_dimensions__ (axis_obj) == 3)
-    ## FIXME -- this works for "axis square", but has not been
-    ##          thoroughly tested for other aspect ratios.
-    aspect_ratio_2d = [max(axis_obj.dataaspectratio(1:2)), ...
-			   axis_obj.dataaspectratio(3)/sqrt(2)];
-  else
-    aspect_ratio_2d = axis_obj.dataaspectratio(1:2);
-  endif
-  orig_fig_units = get (axis_obj.parent, "units");
-  orig_fig_position = get (axis_obj.parent, "units");
-  unwind_protect
-    set (axis_obj.parent, "units", "pixels")
-    fig_position = get (axis_obj.parent, "position");
-    pos_in_pixels = axis_obj.position .* fig_position([3, 4, 3, 4]);
-    orig_aspect_ratio_2d = pos_in_pixels(3:4);
-    rel_aspect_ratio_2d =  aspect_ratio_2d ./ orig_aspect_ratio_2d;
-    rel_aspect_ratio_2d = rel_aspect_ratio_2d ./ max (rel_aspect_ratio_2d);
-    if (rel_aspect_ratio_2d(1) < rel_aspect_ratio_2d(2));
-      dx = (1.0 - rel_aspect_ratio_2d(1)) * pos_in_pixels(3);
-      pos_in_pixels = pos_in_pixels + dx*[0.5, 0.0, -1.0, 0.0];
-    elseif (rel_aspect_ratio_2d(1) > rel_aspect_ratio_2d(2))
-      dy = (1.0 - rel_aspect_ratio_2d(2)) * pos_in_pixels(4);
-      pos_in_pixels = pos_in_pixels + dy*[0.0, 0.5, 0.0, -1.0];
-    endif
-    pos = pos_in_pixels ./ fig_position([3, 4, 3, 4]);
-  unwind_protect_cleanup
-    set (axis_obj.parent, "units", orig_fig_units)
-    set (axis_obj.parent, "units", orig_fig_position)
-  end_unwind_protect
-
-endfunction
-
-function nd = __calc_dimensions__ (obj)
-  kids = obj.children;
-  nd = 2;
-  for i = 1:length (kids)
-    obj = get (kids(i));
-    switch (obj.type)
-      case {"image", "text"}
-        ## ignore as they 
-      case {"line", "patch"}
-        if (! isempty (obj.zdata))
-          nd = 3;
-        endif
-      case "surface"
-        nd = 3;
-      case "hggroup"
-        obj_nd = __calc_dimensions__ (obj);
-        if (obj_nd == 3)
-          nd = 3;
-        endif
-    endswitch
-  endfor
-endfunction
-
--- a/scripts/plot/__area__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-## Copyright (C) 2007, 2008, 2009 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} {} __area__ (@var{ax}, @var{x}, @var{y}, @var{bv}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-function retval = __area__ (ax, x, y, bv, varargin)
-
-  y0 = bv * ones (1, rows (y));
-  y0 = zeros (1, rows (y));
-  retval = [];
-  for i = 1: size (y, 2);
-    hg = hggroup ();
-    retval = [retval; hg];
-    args = __add_datasource__ ("area", hg, {"x", "y"}, varargin{:});
-
-    x1 = x(:, 1).';
-    y1 = y (:, i).';
-    addproperty ("xdata", hg, "data", x1);
-    addproperty ("ydata", hg, "data", y1);
-
-    addlistener (hg, "xdata", @update_data);
-    addlistener (hg, "ydata", @update_data);
-
-    if (i == 1)
-      h = patch (ax, [x1(1), x1, fliplr(x1)], [bv, y1, bv*ones(1, length(y1))],
-		 __next_line_color__ (), "parent", hg);
-    else
-      y1 = y0 + y1;
-      h = patch (ax, [x1(1), x1, fliplr(x1)], [y0(1), y1, fliplr(y0)],
-		 __next_line_color__ (), "parent", hg);
-    endif
-
-    y0 = y1;
-
-    addproperty ("basevalue", hg, "data", bv);
-    addlistener (hg, "basevalue", @move_baseline); 
-
-    addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor"));
-    addproperty ("linewidth", hg, "patchlinewidth", get (h, "linewidth"));
-    addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle"));
-    addproperty ("facecolor", hg, "patchfacecolor", get (h, "facecolor"));
-
-    addlistener (hg, "edgecolor", @update_props);
-    addlistener (hg, "linewidth", @update_props); 
-    addlistener (hg, "linestyle", @update_props); 
-    addlistener (hg, "facecolor", @update_props); 
-
-    addproperty ("areagroup", hg, "data");
-    set (retval, "areagroup", retval);
-
-    if (! isempty (args))
-      set (hg, args{:});
-    endif
-  endfor
-
-endfunction
-
-function update_props (h, d)
-  kids = get (h, "children");
-  set (kids, "edgecolor", get (h, "edgecolor"), 
-       "linewidth", get (h, "linewidth"),
-       "linestyle", get (h, "linestyle"),
-       "facecolor", get (h, "facecolor"));
-endfunction
-
-function move_baseline (h, d)
-  persistent recursion = false;
-
-  ## Don't allow recursion
-  if (! recursion)
-    unwind_protect
-      recursion = true;
-      hlist = get (h, "areagroup");
-      b0 = get (h, "basevalue");
-
-      for hh = hlist(:)'
-	if (hh != h)
-	  b1 = get (hh, "basevalue");
-	  if (b1 != b0)
-	    set (hh, "basevalue", b0);
-	  endif
-	endif
-      endfor
-      update_data (h, d);
-    unwind_protect_cleanup
-      recursion = false;
-    end_unwind_protect
-  endif
-endfunction
-
-function update_data (h, d)
-  hlist = get (h, "areagroup");
-  bv = get (h, "basevalue");
-  for i = 1 : length (hlist)
-    hh = hlist(i);
-    x1 = get (hh, "xdata")(:);
-    y1 = get (hh, "ydata")(:);
-
-    set (get (hh, "children"), "xdata", [x1(1); x1; flipud(x1)]);
-    if (i == 1)
-      set (get (hh, "children"), "ydata", [bv; y1; bv*ones(length(y1), 1)]);
-    else
-      y1 = y0 + y1;
-      set (get (hh, "children"), "ydata", [y0(1); y1; flipud(y0)]);
-    endif      
-
-    y0 = y1;
-  endfor
-endfunction
--- a/scripts/plot/__axes_limits__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-## Copyright (C) 2007, 2008, 2009 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} {} __axes_limits__ (@var{fcn}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-function retval = __axes_limits__ (fcn, varargin)
-
-  retval = [];
-
-  fcnmode = sprintf ("%smode", fcn);
-
-  [h, varargin, nargin] = __plt_get_axis_arg__ (fcn, varargin{:});
-
-  if (nargin == 0)
-    retval = get (h, fcn);
-  else
-    arg = varargin{1};
-
-    if (ischar (arg))
-      if (strcmpi (arg, "mode"))
-	retval = get (h, fcnmode);
-      elseif (strcmpi (arg, "auto") ||  strcmpi (arg, "manual"))
-	set (h, fcnmode, arg);
-      endif
-    else
-      if (!isnumeric (arg) && any (size(arg(:)) != [2, 1]))
-	error ("%s: argument must be a 2 element vector", fcn);
-      else
-	set (h, fcn, arg(:));
-      endif
-    endif
-  endif
-
-endfunction
--- a/scripts/plot/__axis_label__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-## Copyright (C) 1996, 1997, 2000, 2003, 2005, 2006, 2007, 2008,
-##               2009 John W. Eaton 
-##
-## 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} {} __axis_label__ (@var{caller}, @var{txt}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __axis_label__ (caller, txt, varargin)
-
-  if (ischar (txt))
-    ca = gca ();
-
-    h = get (gca (), caller);
-
-    set (h, "fontangle", get (ca, "fontangle"),
-         "fontname", get (ca, "fontname"),
-         "fontsize", get (ca, "fontsize"),
-         "fontunits", get (ca, "fontunits"),
-         "fontweight", get (ca, "fontweight"),
-         "string", txt,
-	 varargin{:});
-
-    if (nargout > 0)
-      retval = h;
-    endif
-  else
-    error ("%s: expecting first argument to be character string", caller);
-  endif
-
-endfunction
--- a/scripts/plot/__bar__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-## Copyright (C) 1996, 1997, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __bar__ (@var{vertical}, @var{func}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function varargout = __bar__ (vertical, func, varargin)
-
-  [h, varargin] = __plt_get_axis_arg__ ((nargout > 1), func, varargin{:});
-
-  ## Slightly smaller than 0.8 to avoid clipping issue in gnuplot 4.0
-  width = 0.8 - 10 * eps; 
-  group = true;
-  bv = 0;
-
-  if (nargin < 3)
-    print_usage ();
-  endif
-
-  if (nargin > 3 && isnumeric (varargin{2}))
-    x = varargin{1};
-    if (isvector (x))
-      x = x(:);
-    endif
-    y = varargin{2};
-    if (isvector (y))
-      y = y(:);
-    endif
-    if (size (x, 1) != size (y, 1))
-      y = varargin{1};
-      if (isvector (y))
-	y = y(:);
-      endif
-      x = [1:size(y,1)]';
-      idx = 2;
-    else
-      if (! isvector (x))
-	error ("%s: x must be a vector", func);
-      endif
-      idx = 3;
-    endif
-  else
-    y = varargin{1};
-    if (isvector (y))
-      y = y(:);
-    endif
-    x = [1:size(y,1)]';
-    idx = 2;
-  endif
-      
-  newargs = {};
-  have_line_spec = false;
-  while (idx <= nargin - 2)
-    if (ischar (varargin{idx}) && strcmpi (varargin{idx}, "grouped"))
-      group = true;
-      idx++;
-    elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "stacked"))
-      group = false;
-      idx++;
-    else
-      if ((ischar (varargin{idx}) || iscell (varargin{idx}))
-	  && ! have_line_spec)
-	[linespec, valid] = __pltopt__ (func, varargin{idx}, false);
-	if (valid)
-	  have_line_spec = true;
-	  newargs = [{linespec.color}, newargs];
-	  idx++;
-	  continue;
-	endif
-      endif
-      if (isscalar(varargin{idx}))
-	width = varargin{idx++};
-      elseif (idx == nargin - 2)
-	newargs = [newargs,varargin(idx++)];
-      elseif (ischar (varargin{idx})
-	      && strcmpi (varargin{idx}, "basevalue")
-	      && isscalar (varargin{idx+1}))
-        bv = varargin{idx+1};
-        idx += 2;
-      else
-	newargs = [newargs,varargin(idx:idx+1)];
-	idx += 2;
-      endif
-    endif
-  endwhile
-
-  xlen = size (x, 1);
-  ylen = size (y, 1);
-
-  if (xlen != ylen)
-    error ("%s: length of x and y must be equal", func);
-  endif
-  if (any (x(2:end) < x(1:end-1)))
-    error ("%s: x vector values must be in ascending order", func);
-  endif
-
-  ycols = size (y, 2);
-  cutoff = min (diff (double(x))) / 2;
-  if (group)
-    delta_p = delta_m = repmat (cutoff * width / ycols, size (x));
-  else
-    delta_p = delta_m = repmat (cutoff * width, size (x));
-  endif
-  x1 = (x - delta_m)(:)';
-  x2 = (x + delta_p)(:)';
-  xb = repmat ([x1; x1; x2; x2](:), 1, ycols);
-
-  if (group)
-    offset = ((delta_p + delta_m) * [-(ycols - 1) / 2 : (ycols - 1) / 2]);
-    xb(1:4:4*ylen,:) += offset;
-    xb(2:4:4*ylen,:) += offset;
-    xb(3:4:4*ylen,:) += offset;
-    xb(4:4:4*ylen,:) += offset;
-    y0 = zeros (size (y)) + bv;
-    y1 = y;
-  else
-    y1 = cumsum(y,2);
-    y0 = [zeros(ylen,1)+bv, y1(:,1:end-1)];
-  endif
-
-  yb = zeros (4*ylen, ycols);
-  yb(1:4:4*ylen,:) = y0;
-  yb(2:4:4*ylen,:) = y1;
-  yb(3:4:4*ylen,:) = y1;
-  yb(4:4:4*ylen,:) = y0;
-
-  xb = reshape (xb, [4, numel(xb) / 4 / ycols, ycols]);
-  yb = reshape (yb, [4, numel(yb) / 4 / ycols, ycols]);
-
-  if (nargout < 2)
-    oldh = gca ();
-    unwind_protect
-      axes (h);
-      newplot ();
-
-      tmp = __bars__ (h, vertical, x, y, xb, yb, width, group,
-		      have_line_spec, bv, newargs{:});
-      if (nargout == 1)
-	varargout{1} = tmp;
-      endif
-    unwind_protect_cleanup
-      axes (oldh);
-    end_unwind_protect
-  else
-    if (vertical)
-      varargout{1} = xb;
-      varargout{2} = yb;
-    else
-      varargout{1} = yb;
-      varargout{2} = xb;
-    endif
-  endif
-
-endfunction
--- a/scripts/plot/__bars__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,274 +0,0 @@
-## Copyright (C) 1996, 1997, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __bars__ (@var{ax}, @var{vertical}, @var{x}, @var{y}, @var{xb}, @var{yb}, @var{width}, @var{group}, @var{have_color_spec}, @var{base_value}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function tmp = __bars__ (ax, vertical, x, y, xb, yb, width, group, have_color_spec, base_value, varargin)
-
-  ycols = columns (y);
-  clim = get (ax, "clim");
-  tmp = [];
-
-  for i = 1:ycols
-    hg = hggroup ();
-    tmp = [tmp; hg];
-    args = __add_datasource__ ("bar", hg, {"x", "y"}, varargin{:});
-    
-    if (vertical)
-      if (! have_color_spec)
-	if (ycols == 1)
-	  lev = clim(1);
-	else
-	  lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
-	endif
-	h = patch(xb(:,:,i), yb(:,:,i), "FaceColor", "flat", 
-		  "cdata", lev, "parent", hg);
-      else
-	h = patch(xb(:,:,i), yb(:,:,i), "parent", hg);
-      endif
-    else
-      if (! have_color_spec)
-	if (ycols == 1)
-	  lev = clim(1)
-	else
-	  lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
-	endif
-	h = patch(yb(:,:,i), xb(:,:,i), "FaceColor", "flat", 
-		  "cdata", lev, "parent", hg);
-      else
-	h = patch(yb(:,:,i), xb(:,:,i), "parent", hg);
-      endif
-    endif
-
-    if (i == 1)
-      x_axis_range = get (ax, "xlim");
-      h_baseline = line (x_axis_range, [0, 0], "color", [0, 0, 0]);
-      set (h_baseline, "handlevisibility", "off");
-      set (h_baseline, "xliminclude", "off");
-      addlistener (ax, "xlim", @update_xlim);
-      addlistener (h_baseline, "ydata", @update_baseline);
-      addlistener (h_baseline, "visible", @update_baseline);
-    endif
-
-    ## Setup the hggroup and listeners
-    addproperty ("showbaseline", hg, "radio", "{on}|off");
-    addproperty ("basevalue", hg, "data", base_value);
-    addproperty ("baseline", hg, "data", h_baseline);
-
-    addlistener (hg, "showbaseline", @show_baseline);
-    addlistener (hg, "basevalue", @move_baseline); 
-
-    addproperty ("barwidth", hg, "data", width);
-    if (group)
-      addproperty ("barlayout", hg, "radio", "stacked|{grouped}", "grouped");
-    else
-      addproperty ("barlayout", hg, "radio", "{stacked}|grouped", "stacked");
-    endif
-    if (vertical)
-      addproperty ("horizontal", hg, "radio", "on|{off}", "off")
-    else
-      addproperty ("horizontal", hg, "radio", "{on}|off", "on")
-    endif
-
-    addlistener (hg, "barwidth", @update_group);
-    addlistener (hg, "barlayout", @update_group);
-    addlistener (hg, "horizontal", @update_group);
-
-    addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor"));
-    addproperty ("linewidth", hg, "patchlinewidth", get (h, "linewidth"));
-    addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle"));
-    addproperty ("facecolor", hg, "patchfacecolor", get (h, "facecolor"));
-
-    addlistener (hg, "edgecolor", @update_props);
-    addlistener (hg, "linewidth", @update_props); 
-    addlistener (hg, "linestyle", @update_props); 
-    addlistener (hg, "facecolor", @update_props); 
-
-    if (isvector (x))
-      addproperty ("xdata", hg, "data", x);
-    else
-      addproperty ("xdata", hg, "data", x(:, i));
-    endif
-    addproperty ("ydata", hg, "data", y(:, i));
- 
-    addlistener (hg, "xdata", @update_data);
-    addlistener (hg, "ydata", @update_data);
-
-    addproperty ("bargroup", hg, "data");
-    set (tmp, "bargroup", tmp);
-    if (! isempty (args))
-      set (hg, args{:});
-    endif
-    if (i == 1)
-      set (h_baseline, "parent", get (hg, "parent"));
-    endif
-  endfor
-
-  update_xlim (ax, []);
-endfunction
-
-function update_xlim (h, d)
-  kids = get (h, "children");
-  xlim = get (h, "xlim");
-
-  for i = 1 : length (kids)
-    obj = get (kids (i));
-    if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline"))
-      if (any (get (obj.baseline, "xdata") != xlim))
-	set (obj.baseline, "xdata", xlim);
-      endif
-    endif
-  endfor
-endfunction
-
-function update_baseline (h, d)
-  visible = get (h, "visible");
-  ydata = get (h, "ydata")(1);
-
-  kids = get (get (h, "parent"), "children");
-  for i = 1 : length (kids)
-    obj = get (kids (i));
-    if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") 
-	&& obj.baseline == h)
-      ## Only alter if changed to avoid recursion of the listener functions
-      if (! strcmpi (get (kids(i), "showbaseline"), visible))
-	set (kids (i), "showbaseline", visible);
-      endif
-      if (! strcmpi (get (kids(i), "basevalue"), visible))
-	set (kids (i), "basevalue", ydata);
-      endif
-    endif
-  endfor
-endfunction
-
-function show_baseline (h, d)
-  persistent recursion = false;
-
-  ## Don't allow recursion
-  if (! recursion)
-    unwind_protect
-      recursion = true;
-      hlist = get (h, "bargroup");
-      showbaseline = get (h, "showbaseline");
-      for hh = hlist(:)'
-	if (hh != h)
-	  set (hh, "showbaseline", showbaseline);
-	endif
-      endfor
-      set (get (h, "baseline"), "visible", showbaseline);
-    unwind_protect_cleanup
-      recursion = false;
-    end_unwind_protect
-  endif
-endfunction
-
-function move_baseline (h, d)
-  b0 = get (h, "basevalue");
-  bl = get (h, "baseline");
-
-  if (get (bl, "ydata") != [b0, b0])
-    set (bl, "ydata", [b0, b0]);
-  endif
-
-  if (strcmpi (get (h, "barlayout"), "grouped"))
-    update_data (h, d);
-  endif
-endfunction
-
-function update_props (h, d)
-  kids = get (h, "children");
-  set (kids, "edgecolor", get (h, "edgecolor"), 
-       "linewidth", get (h, "linewidth"),
-       "linestyle", get (h, "linestyle"),
-       "facecolor", get (h, "facecolor"));
-endfunction
-
-function update_data (h, d)
-  persistent recursion = false;
-
-  ## Don't allow recursion
-  if (! recursion)
-    unwind_protect
-      recursion = true;
-      hlist = get (h, "bargroup");
-      x = get (h, "xdata");
-      if (!isvector (x))
-	x = x(:);
-      endif
-      y = [];
-      for hh = hlist(:)'
-	ytmp = get (hh, "ydata");
-	y = [y ytmp(:)];
-      endfor
-
-      [xb, yb] = bar (x, y, get (h, "barwidth"), get (h, "barlayout"),
-		      "basevalue", get (h, "basevalue"));
-      ny = columns (y);
-      vert = strcmpi (get (h, "horizontal"), "off");
-
-      for i = 1:ny
-	hp = get (hlist(i), "children");
-	if (vert)
-	  set (hp, "xdata", xb(:,:,i), "ydata", yb(:,:,i));
-	else
-	  set (hp, "xdata", yb(:,:,i), "ydata", xb(:,:,i));
-	endif
-      endfor
-    unwind_protect_cleanup
-      recursion = false;
-    end_unwind_protect
-  endif
-endfunction
-
-function update_group (h, d)
-  persistent recursion = false;
-
-  ## Don't allow recursion
-  if (! recursion)
-    unwind_protect
-      recursion = true;
-      hlist = get (h, "bargroup");
-      barwidth = get(h, "barwidth");
-      barlayout = get (h, "barlayout");
-      horizontal = get (h, "horizontal");
-
-      ## To prevent recursion, only change if modified
-      for hh = hlist(:)'
-	if (hh != h)
-	  if (get (hh, "barwidth") != barwidth)
-	    set (hh, "barwidth", barwidth);
-	  endif
-	  if (! strcmpi (get (hh, "barlayout"), barlayout))
-	    set (hh, "barlayout", barlayout);
-	  endif
-	  if (! strcmpi (get (hh, "horizontal"), horizontal))
-	    set (hh, "horizontal", horizontal);
-	  endif
-	endif
-      endfor
-      update_data (h, d);
-    unwind_protect_cleanup
-      recursion = false;
-    end_unwind_protect
-  endif
-endfunction
--- a/scripts/plot/__clabel__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-## Copyright (C) 2008, 2009 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} {@var{h} =} __clabel__ (@var{c}, @var{v}, @var{hparent}, @var{label_spacing}, @var{z}, @var{varargin})
-## Undocumented internal function.
-## @end deftypefn
-
-function h = __clabel__ (c, v, hparent, label_spacing, z, varargin)
-  ## FIXME
-  ## Assume that the plot size is 4 by 3 inches.
-  lims = axis ();
-  xspacing = 72 * 4 / abs(lims(1) - lims(2));
-  yspacing = 72 * 3 / abs(lims(3) - lims(4));
-
-  if (isscalar (hparent) && ishandle(hparent) && 
-	strcmp (get (hparent, "type"), "hggroup"))
-    x = get (hparent, "xdata");
-    xmin = min (x(:));
-    xmax = max (x(:));
-    y = get (hparent, "ydata");
-    ymin = min (y(:));
-    ymax = max (y(:));
-  else
-    i1 = 1;
-    while (i1 < length (c))
-      clev = c(1,i1);
-      clen = c(2,i1);
-      p = c(:, i1+1:i1+clen)      
-
-      xmin = min (c(1,:));
-      xmax = max (c(1,:));
-      ymin = min (c(2,:));
-      ymax = max (c(2,:));
-
-      i1 += clen+1;
-    endwhile
-  endif
-
-  ## Decode contourc output format and place labels.
-  i1 = 1;
-  h = [];
-  while (i1 < length (c))
-    clev = c(1,i1);
-    clen = c(2,i1);
-
-    if (!isempty (v) && ! any (find (clev == v)))
-      i1 += clen+1;
-      continue;
-    endif
-
-    p = c(:, i1+1:i1+clen) .* repmat ([xspacing; yspacing], 1, clen);
-    d = sqrt (sumsq (diff (p, 1, 2)));
-    cumd = cumsum (d);
-    td = sum(d);
-    ntag = ceil (td / label_spacing);
-
-    if (all (c(:,i1+1) == c(:,i1+clen)))
-      Spacing = td / ntag;
-      pos = Spacing / 2 + [0:ntag-1] * Spacing;
-    else
-      pos = zeros(1, ntag);
-      pos(1) = (td - label_spacing * (ntag - 1)) ./ 2;
-      pos(2:ntag) = pos(1) + [1:ntag-1] * label_spacing;
-    endif
-
-    j1 = 2;
-    tlabel = sprintf ("%g", clev);
-    for i = 1 : ntag
-      tagpos = pos(i);
-      
-      while (j1 < clen && cumd(j1) < tagpos)
-	j1++;
-      endwhile
-      tpos = sum(c(:,i1+j1-1:i1+j1), 2) ./ 2;
-
-      if (tpos(1) != xmin &&  tpos(1) != xmax && 
-	  tpos(2) != ymin &&  tpos(2) != ymax)
-	trot = 180 / pi * atan2 (diff (c(2,i1+j1-1:i1+j1)),
-				 diff (c(1,i1+j1-1:i1+j1)));
-
-	if (ischar (z))
-	  ht = text (tpos(1), tpos(2), clev, tlabel, "rotation", trot, 
-		     "parent", hparent, "horizontalalignment", "center",
-		     "userdata", clev, varargin{:});
-	elseif (!isempty (z))
-	  ht = text (tpos(1), tpos(2), z, tlabel, "rotation", trot, 
-		     "parent", hparent, "horizontalalignment", "center",
-		     "userdata", clev, varargin{:});
-	else
-	  ht = text (tpos(1), tpos(2), tlabel, "rotation", trot,
-		     "parent", hparent, "horizontalalignment", "center",
-		     "userdata", clev, varargin{:});
-	endif
-	h = [h; ht];
-      endif
-    endfor
-    i1 += clen+1;
-  endwhile
-endfunction 
\ No newline at end of file
--- a/scripts/plot/__contour__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,514 +0,0 @@
-## Copyright (C) 2007, 2008, 2009 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} {[@var{c}, @var{hg}] =} __contour__ (@dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-function [c, hg] = __contour__ (varargin)
-  ax = varargin{1};
-  zlevel = varargin{2};
-  filled = "off";
-
-  linespec.linestyle = "-";
-  linespec.color = "auto";
-  edgecolor = "flat";
-  for i = 3 : nargin
-    arg = varargin {i};
-    if ((ischar (arg) || iscell (arg)))
-      [linespec, valid] = __pltopt__ ("__contour__", arg, false);
-      if (isempty (linespec.color))
-	linespec.color = "auto";
-      endif
-      if (valid)
-	have_line_spec = true;
-	varargin(i) = [];
-	break;
-      endif
-    endif
-  endfor
-
-  opts = {};
-  i = 3;
-  while (i < length (varargin))
-    if (ischar (varargin {i}))
-      if (strcmpi (varargin{i}, "fill"))
-	filled = varargin {i + 1};
-	varargin(i:i+1) = [];
-      elseif (strcmpi (varargin{i}, "linecolor"))
-	linespec.color = varargin {i + 1};
-	edgecolor = linespec.color;
-	if (ischar (edgecolor) && strcmpi (edgecolor, "auto"))
-	  edgecolor = "flat";
-	endif
-	varargin(i:i+1) = [];
-      elseif (strcmpi (varargin{i}, "edgecolor"))
-	linespec.color = varargin {i + 1};
-	edgecolor = linespec.color;
-	if (ischar (edgecolor) && strcmpi (edgecolor, "flat"))
-	  linespec.color = "auto";
-	endif
-	varargin(i:i+1) = [];
-      else
-	opts{end+1} = varargin{i};
-        varargin(i) = [];
-        opts{end+1} = varargin{i};
-        varargin(i) = [];
-      endif
-    else
-      i++;
-    endif
-  endwhile
-
-  if (length(varargin) < 5)
-    z1 = varargin{3};
-    x1 = 1 : rows(z1);
-    y1 = 1 : columns(z1);
-  else
-    x1 = varargin{3};
-    y1 = varargin{4};
-    z1 = varargin{5};
-  endif
-  if (length (varargin) == 4 || length (varargin) == 6)
-    vn = varargin {end};
-    vnauto = false;
-  else
-    vnauto = true;
-    vn = 10; 
-  endif
-
-  if (isscalar (vn))
-    lvl = linspace (min (z1(!isinf(z1))), max (z1(!isinf(z1))), 
-		    vn + 2)(1:end-1);
-  else
-    lvl = vn;
-  endif
-
-  if (strcmpi (filled, "on"))
-    if (isvector (x1) || isvector (y1))
-      [x1, y1] = meshgrid (x1, y1);
-    endif
-    [nr, nc] = size (z1);
-    x0 = prepad(x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2);
-    x0 = postpad(x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2);
-    x0 = [x0(1, :); x0; x0(1, :)];
-    y0 = prepad(y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1);
-    y0 = postpad(y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1));
-    y0 = [y0(:, 1), y0, y0(:, 1)];
-    z0 = -Inf(nr+2, nc+2);
-    z0(2:nr+1, 2:nc+1) = z1;
-    [c, lev] = contourc (x0, y0, z0, lvl);
-  else
-    [c, lev] = contourc (x1, y1, z1, lvl);
-  endif
-
-  hg = hggroup ();
-  opts = __add_datasource__ ("__countour__", hg, {"x", "y", "z"}, opts{:});
-
-  addproperty ("xdata", hg, "data", x1);
-  addproperty ("ydata", hg, "data", y1);
-  addproperty ("zdata", hg, "data", z1);
-  addproperty ("contourmatrix", hg, "data", c);
-
-  addlistener (hg, "xdata", @update_data);
-  addlistener (hg, "ydata", @update_data);
-  addlistener (hg, "zdata", @update_data);
-  addlistener (hg, "contourmatrix", @update_data);
-
-  addproperty ("fill", hg, "radio", "on|{off}", filled);
-
-  ## The properties zlevel and zlevelmode don't exist in matlab, but
-  ## allow the use of contourgroups with the contour3, meshc and surfc 
-  ## functions. 
-  if (isnumeric (zlevel))
-    addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", "manual")
-    addproperty ("zlevel", hg, "data", zlevel);
-  else
-    addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", zlevel)
-    if (ischar (zlevel) && strcmpi (zlevel, "manual"))
-      z = varargin{3};
-      z = 2 * (min (z(:)) - max (z(:)));
-      addproperty ("zlevel", hg, "data", z);
-    else
-      addproperty ("zlevel", hg, "data", 0.);
-    endif
-  endif
-
-  lvlstep = sum (abs (diff (lvl))) / (length (lvl) - 1);
-
-  addproperty ("levellist", hg, "data", lev);
-  addproperty ("levelstep", hg, "double", lvlstep);
-  if (vnauto)
-    addproperty ("levellistmode", hg, "radio", "{auto}|manual", "auto");
-    addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "auto");
-  elseif (isscalar (vn))
-    addproperty ("levellistmode", hg, "radio", "{auto}|manual", "auto");
-    addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "manual");
-  else
-    addproperty ("levellistmode", hg, "radio", "{auto}|manual", "manual");
-    addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "auto");
-  endif
-
-  addproperty ("labelspacing", hg, "double", 144);
-  addproperty ("textlist", hg, "data", lev);
-  addproperty ("textlistmode", hg, "radio", "{auto}|manual", "auto");
-  addproperty ("textstep", hg, "double", lvlstep);
-  addproperty ("textstepmode", hg, "radio", "{auto}|manual", "auto");
-  addproperty ("showtext", hg, "radio", "on|{off}", "off");
-
-  addproperty ("linecolor", hg, "color", linespec.color, "{auto}|none");
-  addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle);
-  addproperty ("linewidth", hg, "linelinewidth", 0.5);
-
-  ## FIXME It would be good to hide this property which is just an undocumented
-  ## alias for linecolor
-  addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none");
-
-  addlistener (hg, "fill", @update_data);
-
-  addlistener (hg, "zlevelmode", @update_zlevel);
-  addlistener (hg, "zlevel", @update_zlevel);
-
-  addlistener (hg, "levellist", @update_data);
-  addlistener (hg, "levelstep", @update_data);
-  addlistener (hg, "levellistmode", @update_data);
-  addlistener (hg, "levelstepmode", @update_data);
-
-  addlistener (hg, "labelspacing", @update_text);
-  addlistener (hg, "textlist", @update_text);
-  addlistener (hg, "textlistmode", @update_text);
-  addlistener (hg, "textstep", @update_text);
-  addlistener (hg, "textstepmode", @update_text);
-  addlistener (hg, "showtext", @update_text);
-
-  addlistener (hg, "linecolor", @update_line);
-  addlistener (hg, "linestyle", @update_line);
-  addlistener (hg, "linewidth", @update_line);
-
-  addlistener (hg, "edgecolor", @update_edgecolor);
-
-  add_patch_children (hg);
-
-  if (!isempty (opts))
-    set (hg, opts{:});
-  endif
-endfunction
-
-function add_patch_children (hg)
-  c = get (hg, "contourmatrix");
-  lev = get (hg, "levellist");
-  fill = get (hg, "fill");
-  z = get (hg, "zlevel");
-  zmode = get (hg, "zlevelmode");
-  lc = get (hg, "linecolor");
-  lw = get (hg, "linewidth");
-  ls = get (hg, "linestyle");
-  filled = get (hg, "fill");
-
-  if (strcmpi (lc, "auto"))
-    lc = "flat";
-  endif
-
-  if (strcmpi (filled, "on"))
-    if (diff (lev) < 10*eps) 
-      lvl_eps = 1e-6;
-    else
-      lvl_eps = min (diff (lev)) / 1000.0;
-    endif
-
-    ## Decode contourc output format.
-    i1 = 1;
-    ncont = 0;
-    while (i1 < columns (c))
-      ncont++;
-      cont_lev(ncont) = c(1, i1);
-      cont_len(ncont) = c(2, i1);
-      cont_idx(ncont) = i1+1;
-
-      ii = i1+1:i1+cont_len(ncont);
-      cur_cont = c(:, ii);
-      startidx = ii(1);
-      stopidx = ii(end);
-      cont_area(ncont) = polyarea (c(1, ii), c(2, ii));
-      i1 += c(2, i1) + 1;
-    endwhile
-
-    ## Handle for each level the case where we have (a) hole(s) in a patch.
-    ## Those are to be filled with the color of level below or with the
-    ## background colour.
-    for k = 1:numel (lev)
-      lvl_idx = find (abs (cont_lev - lev(k)) < lvl_eps);
-      len = numel (lvl_idx);
-      if (len > 1)
-	## mark = logical(zeros(size(lvl_idx)));
-	mark = false (size (lvl_idx));
-	a = 1;
-	while (a < len)
-	  ## take 1st patch
-          b = a + 1;
-          pa_idx = lvl_idx(a);
-          ## get pointer to contour start, and contour length
-          curr_ct_idx = cont_idx(pa_idx);
-          curr_ct_len = cont_len(pa_idx);
-	  ## get contour
-          curr_ct = c(:, curr_ct_idx:curr_ct_idx+curr_ct_len-1);
-          b_vec = (a+1):len;
-          next_ct_pt_vec = c(:, cont_idx(lvl_idx(b_vec)));
-          in = inpolygon (next_ct_pt_vec(1,:), next_ct_pt_vec(2,:),
-			  curr_ct(1, :), curr_ct(2, :));
-          mark(b_vec(in)) = !mark(b_vec(in));
-          a++;
-	endwhile
-	if (numel (mark) > 0)
-	  ## All marked contours describe a hole in a larger contour of
-	  ## the same level and must be filled with colour of level below.
-          ma_idx = lvl_idx(mark);
-          if (k > 1)
-	    ## Find color of level below.
-            tmp = find(abs(cont_lev - lev(k - 1)) < lvl_eps);
-            lvl_bel_idx = tmp(1);
-	    ## Set color of patches found.
-	    cont_lev(ma_idx) = cont_lev(lvl_bel_idx);
-          else
-	    ## Set lowest level contour to NaN.
-	    cont_lev(ma_idx) = NaN;
-          endif
-	endif
-      endif
-    endfor
-
-    ## The algorithm can create patches with the size of the plotting
-    ## area, we would like to draw only the patch with the highest level.
-    del_idx = [];
-    max_idx = find (cont_area == max (cont_area));
-    if (numel (max_idx) > 1)
-      ## delete double entries
-      del_idx = max_idx(1:end-1);
-      cont_area(del_idx) = cont_lev(del_idx) = [];
-      cont_len(del_idx) = cont_idx(del_idx) = [];
-    endif
-
-    ## Now we have everything together and can start plotting the patches
-    ## beginning with largest area.
-    [tmp, svec] = sort (cont_area);
-    len = ncont - numel (del_idx);
-    h = [];
-    for n = len:(-1):1
-      idx = svec(n);
-      ctmp = c(:, cont_idx(idx):cont_idx(idx) + cont_len(idx) - 1);
-      if (all (ctmp(:,1) == ctmp(:,end)))
-        ctmp(:, end) = [];
-      else
-	## Special case unclosed contours
-      endif
-      h = [h; patch(ctmp(1, :), ctmp(2, :), cont_lev(idx), "edgecolor", lc, 
-		    "linestyle", ls, "linewidth", lw, "parent", hg)];
-    endfor
-
-    if (min (lev) == max (lev))
-      set (gca (), "clim", [min(lev)-1, max(lev)+1]);
-    else
-      set (gca(), "clim", [min(lev), max(lev)]);
-    endif
-
-    set (gca (), "layer", "top");
-  else
-    ## Decode contourc output format.
-    i1 = 1;
-    h = [];
-    while (i1 < length (c))
-      clev = c(1,i1);
-      clen = c(2,i1);
-
-      if (all (c(:,i1+1) == c(:,i1+clen)))
-	p = c(:, i1+1:i1+clen-1);
-      else
-	p = [c(:, i1+1:i1+clen), NaN(2, 1)];
-      endif
-
-      switch (zmode)
-	case "none"
-	  h = [h; patch(p(1,:), p(2,:), "facecolor", "none", 
-			"edgecolor", lc, "linestyle", ls, "linewidth", lw,
-			"cdata", clev, "parent", hg)]; 
-	case "auto"
-	  h = [h; patch(p(1,:), p(2,:), clev * ones (1, columns (p)),
-			"facecolor", "none", "edgecolor", lc, 
-			"linestyle", ls, "linewidth", lw, "cdata", clev, 
-			"parent", hg)];
-	otherwise
-	  h = [h; patch(p(1,:), p(2,:), z * ones (1, columns (p)),
-			"facecolor", "none", "edgecolor", lc,
-			"linestyle", ls, "linewidth", lw, "cdata", clev,
-			"parent", hg)];
-      endswitch
-      i1 += clen+1;
-    endwhile
-  endif
-
-endfunction
-
-function update_zlevel (h, d)
-  z = get (h, "zlevel");
-  zmode = get (h, "zlevelmode");
-  kids = get (h, "children");
-
-  switch (zmode)
-    case "none"
-      set (kids, "zdata", []);
-    case "auto"
-      for i = 1 : length (kids)
-	set (kids(i), "zdata", get (kids (i), "cdata") .* 
-	     ones (size (get (kids (i), "xdata"))));
-      endfor
-    otherwise
-      for i = 1 : length (kids)
-	set (kids(i), "zdata", z .* ones (size (get (kids (i), "xdata"))));
-      endfor
-  endswitch
-endfunction
-
-function update_edgecolor (h, d)
-  ec = get (h, "edgecolor");
-  lc = get (h, "linecolor");
-  if (ischar (ec) && strcmpi (ec, "flat"))
-    if (! strcmpi (lc, "auto"))
-      set (h, "linecolor", "auto");
-    endif
-  elseif (! isequal (ec, lc))
-    set (h, "linecolor", ec);
-  endif
-endfunction
-
-function update_line (h, d)
-  lc = get (h, "linecolor");
-  ec = get (h, "edgecolor");
-  if (strcmpi (lc, "auto"))
-    lc = "flat";
-  endif
-  if (! isequal (ec, lc))
-    set (h, "edgecolor", lc);
-  endif
-  set (findobj (h, "type", "patch"), "edgecolor", lc,
-       "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"));
-endfunction
-
-function update_data (h, d)
-  persistent recursive = false;
-
-  if (!recursive)
-    recursive = true;
-
-    delete (get (h, "children"));
-
-    if (strcmpi (get (h, "levellistmode"), "manual"))
-      lvl = get (h, "levellist");
-    elseif (strcmpi (get (h, "levelstepmode"), "manual"))
-      z = get (h, "zdata");
-      lvl = ceil ((max(z(:)) - min (z(:)) ./ get (h, "levelstep")));
-    else
-      lvl = 10;
-    endif
-
-    if (strcmpi (get (h, "fill"), "on"))
-      X = get (h, "xdata");
-      Y = get (h, "ydata");
-      Z = get (h, "zdata");
-      if (isvector (X) || isvector (Y))
-	[X, Y] = meshgrid (X, Y);
-      endif
-      [nr, nc] = size (Z);
-      X0 = prepad(X, nc+1, 2 * X(1, 1) - X(1, 2), 2);
-      X0 = postpad(X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2);
-      X0 = [X0(1, :); X0; X0(1, :)];
-      Y0 = prepad(Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1);
-      Y0 = postpad(Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1));
-      Y0 = [Y0(:, 1), Y0, Y0(:, 1)];
-      Z0 = -Inf(nr+2, nc+2);
-      Z0(2:nr+1, 2:nc+1) = Z;
-      [c, lev] = contourc (X0, Y0, Z0, lvl);
-    else
-      [c, lev] = contourc (get (h, "xdata"), get (h, "ydata"), 
-			   get (h, "zdata"), lvl); 
-    endif
-    set (h, "contourmatrix", c);
-
-    if (strcmpi (get (h, "levellistmode"), "manual"))
-      ## Do nothing
-    elseif (strcmpi (get (h, "levelstepmode"), "manual"))
-      set (h, "levellist", lev);
-    else
-      set (h, "levellist", lev);
-      z = get (h, "zdata");
-      lvlstep = (max(z(:)) - min(z(:))) / 10;
-      set (h, "levelstep", lvlstep);
-    endif
-
-    add_patch_children (h);
-    update_text (h, d);
-  endif
-
-  recursive = false;
-endfunction
-
-function update_text (h, d)
-  persistent recursive = false;
-
-  if (!recursive)
-    recursive = true;
-
-    delete (findobj (h, "type", "text"));
-
-    if (strcmpi (get (h, "textlistmode"), "manual"))
-      lvl = get (h, "textlist");
-    elseif (strcmpi (get (h, "textstepmode"), "manual"))
-      lev = get (h, "levellist");
-
-      if (diff (lev) < 10*eps) 
-	lvl_eps = 1e-6;
-      else
-	lvl_eps = min (abs (diff (lev))) / 1000.0;
-      endif
-
-      stp = get (h, "textstep");
-      t = [0, floor(cumsum(diff (lev)) / (abs(stp) - lvl_eps))];
-      lvl = lev([true, t(1:end-1) != t(2:end)]);
-      set (h, "textlist", lvl);
-    else
-      lvl = get (h, "levellist");
-      set (h, "textlist", lvl, "textstep", get (h, "levelstep"));
-    endif
-
-    if (strcmpi (get (h, "showtext"), "on"))
-      switch (get (h, "zlevelmode"))
-	case "manual"
-	  __clabel__ (get (h, "contourmatrix"), lvl, h, 
-		      get (h, "labelspacing"), get (h, "zlevel"));
-	case "auto"
-	  __clabel__ (get (h, "contourmatrix"), lvl, h,
-		      get (h, "labelspacing"), "auto");
-	otherwise
-	  __clabel__ (get (h, "contourmatrix"), lvl, h,
-		      get (h, "labelspacing"), []);
-      endswitch
-    endif
-  endif
-
-  recursive = false;
-endfunction
--- a/scripts/plot/__default_plot_options__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-## Copyright (C) 2007, 2009 John W. Eaton
-##
-## 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} {@var{options} =} __default_plot_options__ ()
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function options = __default_plot_options__ ()
-
-  options.key = "";
-  options.color = [];
-  options.linestyle = "-";
-  options.marker = "none";
-
-endfunction
--- a/scripts/plot/__errcomm__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Teemu Ikonen
-##
-## 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} {} __errcomm__ (@var{caller}, @var{p}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-## Created: 20.02.2001
-## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
-## Keywords: errorbar, plotting
-
-function retval = __errcomm__ (caller, p, varargin)
-
-  if (nargin < 4)
-    print_usage ();
-  endif
-
-  nargs = length (varargin);
-
-  k = 1;
-  idx = 1;
-  data = cell(6,1);
-  while (k <= nargs)
-    a = varargin{k++};
-    if (isvector (a))
-      a = a(:);
-    elseif (ismatrix (a))
-      ;
-    else
-      usage ("%s (...)", caller);
-    endif
-    sz = size (a);
-    ndata = 1;
-    data{ndata} = a;
-    while (k <= nargs)
-      a = varargin{k++};
-      if (ischar (a) || iscellstr (a))
-	retval(idx++) = __errplot__ (a, p, data{1:ndata});
-	break;
-      elseif (isvector (a))
-	a = a(:);
-      elseif (ismatrix (a))
-	;
-      else
-	error ("wrong argument types");
-      endif
-      if (size (a) != sz)
-	error ("argument sizes do not match");
-      endif
-      data{++ndata} = a;
-      if (ndata > 6)
-	error ("too many arguments to a plot");
-      endif
-    endwhile
-  endwhile
-
-  if (! (ischar (a) || iscellstr (a)))
-    retval(idx++) = __errplot__ ("~", p, data{1:ndata});
-  endif
-
-  drawnow ();
-
-endfunction
--- a/scripts/plot/__errplot__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-##               Teemu Ikonen
-##
-## 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} {@var{h} =} __errplot__ (@var{fstr}, @var{p}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-## Created: 18.7.2000
-## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
-## Keywords: errorbar, plotting
-
-function h = __errplot__ (fstr, p, a1, a2, a3, a4, a5, a6)
-
-  if (nargin < 4 || nargin > 8) # at least two data arguments needed
-    print_usage ();
-  endif
-
-  [fmt, key] = __pltopt__ ("__errplot__", fstr);
-
-  [len, nplots] = size (a1);
-  h = [];
-
-  for i = 1:nplots
-    ## Set the plot type based on linestyle.
-
-    if (strcmp (fmt.linestyle, "~"))
-      ifmt = "yerr";
-    elseif (strcmp (fmt.linestyle, ">"))
-      ifmt = "xerr";
-    elseif (strcmp (fmt.linestyle, "~>"))
-      ifmt = "xyerr";
-    elseif (strcmp (fmt.linestyle, "#"))
-      ifmt = "box";
-    elseif (strcmp (fmt.linestyle, "#~"))
-      ifmt = "boxy";
-    elseif (strcmp (fmt.linestyle, "#~>"))
-      ifmt = "boxxy";
-    else
-      print_usage ();
-    endif
-
-    hg = hggroup ("parent", p);
-    h = [h; hg];
-    args = __add_datasource__ ("__errplot__", hg, 
-			       {"x", "y", "l", "u", "xl", "xu"});
-
-    if (isempty (fmt.color))
-      hl = __line__ (hg, "color", __next_line_color__ ());
-    else
-      hl = __line__ (hg, "color", fmt.color);
-    endif
-
-    ## FIXME -- note the code below adds the errorbar data directly as
-    ## ldata, etc properties of the line objects, as gnuplot can handle
-    ## this.  Matlab has the errorbar part of the plot as a special line
-    ## object with embedded NaNs that draws the three segments of the
-    ## bar separately.  Should we duplicate Matlab's behavior and stop
-    ## using the ldata, etc. properties of the line objects that are
-    ## Octace specific?
-
-    switch (nargin - 2)
-      case 1
-	error ("error plot requires 2, 3, 4 or 6 columns");
-      case 2
-	set (hl, "xdata", (1:len)');
-	set (hl, "ydata", a1(:,i));
-	set (hl, "ldata", a2(:,i));
-	set (hl, "udata", a2(:,i));
-      case 3
-	set (hl, "xdata", a1(:,i));
-	set (hl, "ydata", a2(:,i));
-	set (hl, "ldata", a3(:,i));
-	set (hl, "udata", a3(:,i));
-      case 4
-	set (hl, "xdata", a1(:,i));
-	set (hl, "ydata", a2(:,i));
-
-	if (index (ifmt, "boxxy") || index (ifmt, "xyerr"))
-	  set (hl, "xldata", a3(:,i));
-	  set (hl, "xudata", a3(:,i));
-	  set (hl, "ldata", a4(:,i));
-	  set (hl, "udata", a4(:,i));
-	elseif (index (ifmt, "xerr"))
-	  set (hl, "xldata", a3(:,i));
-	  set (hl, "xudata", a4(:,i));
-	else
-	  set (hl, "ldata", a3(:,i));
-	  set (hl, "udata", a4(:,i));
-	endif
-      case 5
-	error ("error plot requires 2, 3, 4 or 6 columns");
-      case 6
-	set (hl, "xdata", a1(:,i));
-	set (hl, "ydata", a2(:,i));
-	set (hl, "xldata", a3(:,i));
-	set (hl, "xudata", a4(:,i));
-	set (hl, "ldata", a5(:,i));
-	set (hl, "udata", a6(:,i));
-    endswitch
-
-    addproperty ("color", hg, "linecolor", get (hl, "color"));
-    addproperty ("linewidth", hg, "linelinewidth", get (hl, "linewidth"));
-    addproperty ("linestyle", hg, "linelinestyle", get (hl, "linestyle"));
-    addproperty ("marker", hg, "linemarker", get (hl, "marker"));
-    addproperty ("markerfacecolor", hg, "linemarkerfacecolor", 
-		 get (hl, "markerfacecolor"));
-    addproperty ("markeredgecolor", hg, "linemarkerfacecolor", 
-		 get (hl, "markeredgecolor"));
-    addproperty ("markersize", hg, "linemarkersize", 
-		 get (hl, "markersize"));
-
-    addlistener (hg, "color", @update_props);
-    addlistener (hg, "linewidth", @update_props); 
-    addlistener (hg, "linestyle", @update_props); 
-    addlistener (hg, "marker", @update_props); 
-    addlistener (hg, "markerfacecolor", @update_props); 
-    addlistener (hg, "markersize", @update_props);
-
-    addproperty ("xdata", hg, "data", get (hl, "xdata"));
-    addproperty ("ydata", hg, "data", get (hl, "ydata"));
-    addproperty ("ldata", hg, "data", get (hl, "ldata"));
-    addproperty ("udata", hg, "data", get (hl, "udata"));
-    addproperty ("xldata", hg, "data", get (hl, "xldata"));
-    addproperty ("xudata", hg, "data", get (hl, "xudata"));
-
-    addlistener (hg, "xdata", @update_data);
-    addlistener (hg, "ydata", @update_data);
-    addlistener (hg, "ldata", @update_data);
-    addlistener (hg, "udata", @update_data);
-    addlistener (hg, "xldata", @update_data);
-    addlistener (hg, "xudata", @update_data);
-
-    __line__ (hg, "xdata", get (hl, "xdata"), 
-	      "ydata", get (hl, "ydata"), 
-	      "color", get (hl, "color"),
-	      "linewidth", get (hl, "linewidth"),
-	      "linestyle", get (hl, "linestyle"), 
-	      "marker", "none", "parent", hg);
-  endfor
-
-endfunction
-
-function update_props (h, d)
-  set (get (h, "children"), "color", get (h, "color"), 
-       "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"), 
-       "marker", get (h, "marker"), "markersize", get (h, "markersize"),
-       "markerfacecolor", get (h, "markerfacecolor"),
-       "markeredgecolor", get (h, "markeredgecolor"));
-endfunction
-
-function update_data (h, d)
-  x = get (h, "xdata");
-  y = get (h, "ydata");
-  l = get (h, "ldata");
-  u = get (h, "udata");
-  xl = get (h, "xldata");
-  xu = get (h, "xudata");
-
-  kids = get (h, "children");
-  set (kids(1), "xdata", x, "ydata", y);
-  set (kids(2), "xdata", x, "ydata", y, "ldata", l, "udata", u, 
-       "xldata", xl, "xudata", xu);
-endfunction
--- a/scripts/plot/__ezplot__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,445 +0,0 @@
-## Copyright (C) 2007, 2008, 2009 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} {[@var{h}, @var{needusage}] =} __ezplot__ (@var{pfunc}, @var{varargin})
-## Undocumented internal function.
-## @end deftypefn
-
-function [h, needusage] = __ezplot__ (pfunc, varargin)
-
-  func = cstrcat ("ez", pfunc);
-  if (strncmp (pfunc, "contour", 7))
-    iscontour = true;
-  else
-    iscontour = false;
-  endif
-  if (strcmp (pfunc, "plot"))
-    isplot = true;
-    isplot3 = false;
-    ispolar = false;
-    nargs = 1;
-  elseif (strcmp (pfunc, "plot3"))
-    isplot = false;
-    isplot3 = true;
-    ispolar = false;
-    nargs = 1;
-  elseif (strcmp (pfunc, "polar"))
-    isplot = false;
-    isplot3 = false;
-    ispolar = true;
-    nargs = 1;
-  else
-    isplot = false;
-    isplot3 = false;
-    ispolar = false;
-    nargs = 2;
-  endif
-
-  [ax, varargin, nargin] = __plt_get_axis_arg__ (func, varargin{:});
-
-  needusage = false;
-  if (nargin < 1)
-    needusage = true;
-    return;
-  endif
-
-  parametric = false;
-  fun = varargin {1};
-  if (ischar (fun))
-    if (exist (fun, "file") || exist (fun, "builtin"))
-      fun = vectorize (inline (cstrcat (fun, "(t)")));
-    else
-      fun = vectorize (inline (fun));
-    endif
-    if (isplot && length (argnames (fun)) == 2)
-      nargs = 2;
-    elseif (length (argnames (fun)) != nargs)
-      error ("%s: excepting a function of %d arguments", func, nargs);
-    endif
-    fstr = formula (fun);
-    if (isplot)
-      xarg = argnames(fun){1};
-      if (nargs == 2)
-	yarg = argnames(fun){2};
-      else
-	yarg = "";
-      endif
-    elseif (isplot3)
-      xarg = "x";
-      yarg = "y";
-    elseif (ispolar)
-      xarg = "";
-      yarg = "";
-    else
-      xarg = argnames(fun){1};
-      yarg = argnames(fun){2};
-    endif
-  elseif (strcmp (typeinfo (fun), "inline function"))
-    if (isplot && length (argnames (fun)) == 2)
-      nargs = 2;
-    elseif (length (argnames (fun)) != nargs)
-      error ("%s: excepting a function of %d arguments", func, nargs);
-    endif
-    fun = vectorize (fun);
-    fstr = formula (fun);
-    if (isplot)
-      xarg = argnames(fun){1};
-      if (nargs == 2)
-	yarg = argnames(fun){2};
-      else
-	yarg = "";
-      endif
-    elseif (isplot3)
-      xarg = "x";
-      yarg = "y";
-    elseif (isplot || ispolar)
-      xarg = "";
-      yarg = "";
-    else
-      xarg = argnames(fun)(1);
-      yarg = argnames(fun)(2);
-    endif
-  elseif (isa (fun, "function_handle"))
-    fstr = func2str (fun);
-    if (length (findstr (fstr, ")")) != 0)
-      args = regexp (substr (fstr, 3, findstr (fstr, ")")(1) - 3), 
-		     '(\w[\w\d]*)', 'tokens');
-    fstr = substr (fstr, findstr (fstr, ")")(1) + 1);
-    else
-      args = {{"x"}};
-    endif
-    if (isplot && length (args) == 2)
-      nargs = 2;
-    elseif (length (args) != nargs)
-      error ("%s: excepting a function of %d arguments", func, nargs);
-    endif
-    if (isplot)
-      xarg = args{1}{1};
-      if (nargs == 2)
-	yarg = args{2}{1};
-      else
-	yarg = "";
-      endif
-    elseif (isplot3)
-      xarg = "x";
-      yarg = "y";
-    elseif (ispolar)
-      xarg = "";
-      yarg = "";
-    else
-      xarg = args{1}{1};
-      yarg = args{2}{1};
-    endif
-  else
-    error ("%s: expecting string, inline function or function handle", func);
-  endif
-
-  if (nargin > 2 || (nargin == 2 && isplot))
-    funx = fun;
-    fstrx = fstr;
-    funy = varargin {2};
-    if (ischar (funy) && ! strcmp (funy, "circ") && ! strcmp (funy, "animate"))
-      parametric = true;
-      if (exist (funy, "file") || exist (funy, "builtin"))
-	funy = vectorize (inline (cstrcat (funy, "(t)")));
-      else
-	funy = vectorize (inline (funy));
-      endif
-      if (length (argnames (funy)) != nargs)
-	error ("%s: excepting a function of %d arguments", func, nargs);
-      endif
-      fstry = formula (funy);
-    elseif (strcmp (typeinfo (funy), "inline function"))
-      parametric = true;
-      if (length (argnames (funy)) != nargs)
-	error ("%s: excepting a function of %d arguments", func, nargs);
-      endif
-      funy = vectorize (funy);
-      fstry = formula (funy);
-    elseif (isa (funy, "function_handle"))
-      parametric = true;
-      fstry = func2str (funy);
-      if (length (findstr (fstry, ")")) != 0)
-	args = regexp (substr (fstry, 3, findstr (fstry, ")")(1) - 3), 
-		       '(\w[\w\d]*)', 'tokens');
-	fstry = substr (fstry, findstr (fstry, ")")(1) + 1);
-      else
-	args = {{"y"}};
-      endif
-      if (length (args) != nargs)
-	error ("%s: excepting a function of %d arguments", func, nargs);
-      endif
-    endif
-
-    if (parametric && isplot)
-      xarg = "x";
-      yarg = "y";
-      if (nargs == 2)
-	error ("%s: can not define a parametric function in this manner");
-      endif
-    endif
-
-    if (!isplot && parametric)
-      funz = varargin {3};
-      if (ischar (funz) && ! strcmp (funz, "circ") && 
-	  ! strcmp (funz, "animate"))
-	if (exist (funz, "file") || exist (funz, "builtin"))
-	  funz = vectorize (inline (cstrcat (funz, "(t)")));
-	else
-	  funz = vectorize (inline (funz));
-	endif
-	if (length (argnames (funz)) != nargs)
-	  error ("%s: excepting a function of %d arguments", func, nargs);
-	endif
-	fstrz = formula (funz);
-      elseif (strcmp (typeinfo (funz), "inline function"))
-	if (length (argnames (funz)) != nargs)
-	  error ("%s: excepting a function of %d arguments", func, nargs);
-	endif
-	funz = vectorize (funz);
-	fstrz = formula (funz);
-      elseif (isa (funz, "function_handle"))
-	fstrz = func2str (funz);
-	args = regexp (substr (fstrz, 3, findstr (fstrz, ")")(1) - 3), 
-		       '(\w[\w\d]*)', 'tokens');
-	if (length (args) != nargs)
-	  error ("%s: excepting a function of %d arguments", func, nargs);
-	endif
-	fstrz = substr (fstrz, findstr (fstrz, ")")(1) + 1);
-      else
-	error ("%s: parametric plots expect 3 functions", func);
-      endif
-    endif
-  endif
-
-  if (isplot && nargs != 2)
-    n = 500; 
-  else
-    n = 60;
-  endif
-  domain = [];
-  circ = false;
-  animate = false;
-  if (parametric)
-    if (isplot)
-      iarg = 3;
-    else
-      iarg = 4;
-    endif
-  else
-    iarg = 2;
-  endif
-  while (iarg <= nargin)
-    arg = varargin{iarg++};
-    if (ischar (arg) && strcmp (arg, "circ"))
-      circ = true;
-    elseif (ischar (arg) && strcmp (arg, "animate"))
-      animate = true;
-    elseif (isscalar (arg))
-      n = arg;
-    elseif (numel (arg) == 2)
-      domain = [arg(:).' arg(:).'];
-    elseif (numel (arg) == 4)
-      domain = arg(:).';
-    else
-      error ("%s: expecting scalar, 2 or 4 element vector", func);
-    endif
-  endwhile
-
-  if (isempty (domain))
-    if (isplot3 || ispolar)
-      domain = [0, 2*pi, 0, 2*pi];
-    else
-      domain = [-2*pi, 2*pi, -2*pi, 2*pi];
-    endif
-  endif
-
-  if (circ)
-    if (iscontour || isplot3 || isplot)
-      needusage = true;
-      return;
-    endif
-    if (parametric)
-      error ("%s: can not have both circular domain and parametric function", 
-	     func);
-    endif
-    cent = [domain(1) + domain(2), domain(3) + domain(4)] / 2;
-    funx = @(r,t) r .* cos (t) + cent (1);
-    funy = @(r,t) r .* sin (t) + cent (2);
-    domain = [0, sqrt((domain(2) - cent(1))^2 + (domain(4) - cent(2))^2), ...
-	      -pi, pi];
-    funz = fun;
-    parametric = true;
-  endif
-
-  if (animate)
-    if (!isplot3)
-      error ("%s: animated graphs only valid with plot3", func);
-    endif
-    error ("%s: animated graphs not implemented", func);
-  endif
-
-  if (isplot3 || ispolar || (isplot && nargs == 1))
-    X = linspace (domain (1), domain (2), n);
-  elseif (isplot && numel (domain) == 2)
-    x = linspace (domain (1), domain (2), n);
-    [X, Y] = meshgrid (x, x);
-  else
-    x = linspace (domain (1), domain (2), n);
-    y = linspace (domain (3), domain (4), n);
-    [X, Y] = meshgrid (x, y);
-  endif
-
-  if (parametric)
-    if (isplot)
-      XX = feval (funx, X);
-      Z = feval (funy, X);
-      X = XX;
-    elseif (isplot3)
-      Z = feval (funz, X);
-      XX = feval (funx, X);
-      YY = feval (funy, X);
-      X = XX;
-      Y = YY;
-    else
-      Z = feval (funz, X, Y);
-      XX = feval (funx, X, Y);
-      YY = feval (funy, X, Y);
-      X = XX;
-      Y = YY;
-
-      ## Eliminate the singularities
-      X = __eliminate_sing__ (X);
-      Y = __eliminate_sing__ (Y);
-      Z = __eliminate_sing__ (Z);
-    endif
-
-    fstrx = regexprep (regexprep (regexprep (fstrx,'\.\^\s*','^'), 
-		      '\./', '/'), '[\.]*\*', '');
-    fstry = regexprep (regexprep (regexprep (fstry,'\.\^\s*','^'), 
-		      '\./', '/'), '[\.]*\*', '');
-    if (isplot)
-      fstr = cstrcat ("x = ",fstrx,", y = ",fstry);
-    else
-      fstrz = regexprep (regexprep (regexprep (fstrz,'\.\^\s*','^'), 
-				    '\./', '/'), '[\.]*\*', '');
-      fstr = cstrcat ("x = ",fstrx,",y = ",fstry,", z = ",fstrz);
-    endif
-  else
-    if (isplot3)
-      needusage = true;
-      return;
-    endif
-
-    fstr = regexprep (regexprep (regexprep (fstr,'\.\^\s*','^'), '\./', '/'), 
-		      '[\.]*\*', '');
-    if (isplot && nargs == 2)
-      if (strcmp (typeinfo (fun), "inline function") && 
-	  !isempty (strfind (formula (fun) , "=")))
-	fun = inline (cstrcat (strrep (formula (fun), "=", "- ("), ")"));
-      else
-	fstr = cstrcat (fstr, " = 0");
-      endif
-
-      Z = feval (fun, X, Y);
-
-      ## Matlab returns line objects for this case and so can't call 
-      ## contour directly as it returns patch objects to allow colormaps
-      ## to work with contours. Therefore recreate the lines from the
-      ## output for contourc, and store in cell arrays.
-      [c, lev] = contourc (X, Y, Z, [0, 0]);
-
-      i1 = 1;
-      XX = {};
-      YY = {};
-      while (i1 < length (c))
-	clev = c(1,i1);
-	clen = c(2,i1);
-	XX = [XX, {c(1, i1+1:i1+clen)}];
-	YY = [YY, {c(2, i1+1:i1+clen)}];
-	i1 += clen+1;
-      endwhile
-    else  
-      if (ispolar)
-	Z = feval (fun, X);
-      elseif (isplot)
-	Z = real (feval (fun, X));
-
-	## Eliminate the singularities. This seems to be what matlab
-	## does, but can't be sure.
-	XX = sort (Z (isfinite (Z)));
-	if (length (X) > 4)
-	  d = XX(fix (7 * length (XX) / 8)) - XX(fix (length (XX) / 8));
-	  yrange = [max(XX(1) - d/8, XX(fix (length (XX) / 8)) - d), ...
-		    min(XX(end) + d/8, XX(fix (7 * length (XX) / 8)) + d)];
-	else
-	  yrange = [XX(1), XX(end)];
-        endif
-
-	idx = 2 : length(Z);
-	idx = find (((Z(idx) > yrange(2) / 2) & (Z(idx-1) < yrange(1) / 2)) |
-		 ((Z(idx) < yrange(1) / 2) & (Z(idx-1) > yrange (2) / 2)));
-	if (any(idx))
-	  Z(idx) = NaN; 
-	endif
-      else
-	Z = feval (fun, X, Y);
-
-	## Eliminate the singularities
-	Z = __eliminate_sing__ (Z);
-      endif
-    endif
-  endif
-
-  oldax = gca (); 
-  unwind_protect
-    axes (ax);
-    if (iscontour)
-      [clev, h] = feval (pfunc, X, Y, Z);
-    elseif (isplot && nargs == 2)
-      h = [];
-      hold_state = get (ax, "nextplot");
-      for i = 1 : length (XX)
-	h = [h; plot(XX{i}, YY{i})];
-	if (i == 1)
-	  set (ax, "nextplot", "add")
-	endif
-      endfor
-      set (ax, "nextplot", hold_state)
-    elseif (ispolar || isplot)
-      h = feval (pfunc, X, Z);
-      if (isplot && !parametric)
-	axis ([X(1), X(end), yrange]);
-      endif
-    else
-      h = feval (pfunc, X, Y, Z);
-    endif
-    xlabel (xarg);
-    ylabel (yarg);
-    title (fstr);
-  unwind_protect_cleanup
-    axes (oldax);
-  end_unwind_protect
-
-endfunction
-
-function x = __eliminate_sing__ (x)
-  x (isinf (x)) = NaN;
-  x (abs (del2 (x)) > 0.2 * (max(x(:)) - min(x(:)))) = NaN;
-endfunction
--- a/scripts/plot/__interp_cube__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-## Copyright (C) 2009 Martin Helm
-##
-## This program 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.
-##
-## This program 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 this program; if not, see http://www.gnu.org/licenses/gpl.html.
-##
-## Author: Martin Helm <martin@mhelm.de>
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {[@var{vxyz}, @var{idx}, @var{frac}] =} __interp_cube__ (@var{x}, @var{y}, @var{z}, @var{val}, @var{v})
-## Undocumented internal function.
-## @end deftypefn
-
-function [Vxyz, idx, frac] = __interp_cube__(x, y, z, val, v, req = "values" )
-  if (ismatrix (x) && ndims (x) == 3 && ismatrix (y) && ndims (y) == 3 ...
-       && ismatrix (z) && ndims (z) == 3 && size_equal (x, y, z, val))
-    x = squeeze (x(1,:,1))(:);
-    y = squeeze (y(:,1,1))(:);
-    z = squeeze (z(1,1,:))(:);
-  elseif (isvector (x) && isvector (y) && isvector (z) )
-    x = x(:);
-    y = y(:);
-    z = z(:);
-  else
-    error("x, y, z have wrong dimensions");
-  endif
-  if (size (val) != [length(x), length(y), length(z)])
-    error ("val has wrong dimensions");
-  endif
-  if (size (v, 2) != 3)
-    error ( "v has to be N*3 matrix");
-  endif
-  if (!ischar (req))
-   error ("Invalid request parameter use 'values', 'normals' or 'normals8'");
-  endif
-  if (isempty (v))
-    Vxyz = idx = frac = [];
-    return
-  endif
-
-  switch req
-    case "values"
-      [Vxyz, idx, frac] = interp_cube_trilin (x, y, z, val, v);
-    case "normals"
-      [idx, frac] = cube_idx (x, y, z, v);
-
-      dx = x(2:end) - x(1:end-1);
-      dy = y(2:end) - y(1:end-1);
-      dz = z(2:end) - z(1:end-1);
-      dx = 0.5 .* [dx;dx(end)](idx(:,2));
-      dy = 0.5 .* [dy;dy(end)](idx(:,1));
-      dz = 0.5 .* [dz;dz(end)](idx(:,3));
-
-      p000 = [v(:, 1) - dx, v(:, 2) - dy, v(:, 3) - dz];
-      p100 = [v(:, 1) + dx, v(:, 2) - dy, v(:, 3) - dz];
-      p010 = [v(:, 1) - dx, v(:, 2) + dy, v(:, 3) - dz];
-      p001 = [v(:, 1) - dx, v(:, 2) - dy, v(:, 3) + dz];
-      p011 = [v(:, 1) - dx, v(:, 2) + dy, v(:, 3) + dz];
-      p101 = [v(:, 1) + dx, v(:, 2) - dy, v(:, 3) + dz];
-      p110 = [v(:, 1) + dx, v(:, 2) + dy, v(:, 3) - dz];
-      p111 = [v(:, 1) + dx, v(:, 2) + dy, v(:, 3) + dz];
-
-      v000 = interp_cube_trilin (x, y, z, val, p000);
-      v100 = interp_cube_trilin (x, y, z, val, p100);
-      v010 = interp_cube_trilin (x, y, z, val, p010);
-      v001 = interp_cube_trilin (x, y, z, val, p001);
-      v011 = interp_cube_trilin (x, y, z, val, p011);
-      v101 = interp_cube_trilin (x, y, z, val, p101);
-      v110 = interp_cube_trilin (x, y, z, val, p110);
-      v111 = interp_cube_trilin (x, y, z, val, p111);
-
-      Dx = -v000 .+ v100 .- v010 .- v001 .- v011 .+ v101 .+ v110 .+ v111;
-      Dy = -v000 .- v100 .+ v010 .- v001 .+ v011 .- v101 .+ v110 .+ v111;
-      Dz = -v000 .- v100 .- v010 .+ v001 .+ v011 .+ v101 .- v110 .+ v111;
-      Vxyz = 0.5 .* [Dx./dx, Dy./dy, Dz./dz];
-    case "normals8"
-      [idx, frac] = cube_idx (x, y, z, v);
-
-      dx = x(2:end) - x(1:end-1);
-      dy = y(2:end) - y(1:end-1);
-      dz = z(2:end) - z(1:end-1);
-      dx = [dx;dx(end)](idx(:,2));
-      dy = [dy;dy(end)](idx(:,1));
-      dz = [dz;dz(end)](idx(:,3));
-      [Dx, Dy, Dz, idx, frac] = interp_cube_trilin_grad (x, y, z, val, v);
-      Vxyz = [Dx./dx, Dy./dy, Dz./dz];
-   otherwise
-     error ("Invalid request type '%s', use 'values', 'normals' or 'normals8'", req);
-  endswitch
-endfunction
-
-function [Vxyz, idx, frac] = interp_cube_trilin(x, y, z, val, v)
-  [idx, frac] = cube_idx (x(:), y(:), z(:), v);
-  sval = size (val);
-  i000 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3));
-  i100 = sub2ind (sval, idx(:, 1)+1, idx(:, 2), idx(:, 3));
-  i010 = sub2ind (sval, idx(:, 1), idx(:, 2)+1, idx(:, 3));
-  i001 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3)+1);
-  i101 = sub2ind (sval, idx(:, 1)+1, idx(:, 2), idx(:, 3)+1);
-  i011 = sub2ind (sval, idx(:, 1), idx(:, 2)+1, idx(:, 3)+1);
-  i110 = sub2ind (sval, idx(:, 1)+1, idx(:, 2)+1, idx(:, 3));
-  i111 = sub2ind (sval, idx(:, 1)+1, idx(:, 2)+1, idx(:, 3)+1 );
-  Bx = frac(:, 1);
-  By = frac(:, 2);
-  Bz = frac(:, 3);
-  Vxyz = ...
-    val( i000 ) .* (1 .- Bx) .* (1 .- By) .* (1 .- Bz) .+ ...
-    val( i100 ) .* Bx .* (1 .- By) .* (1 .- Bz) .+ ...
-    val( i010 ) .* (1 .- Bx) .* By .* (1 .- Bz) .+ ...
-    val( i001 ) .* (1 .- Bx) .* (1 .- By) .* Bz .+ ...
-    val( i011 ) .* (1 .- Bx) .* By .* Bz .+ ...
-    val( i101 ) .* Bx .* (1 .- By) .* Bz .+ ...
-    val( i110 ) .* Bx .* By .* (1 .- Bz) .+ ...
-    val( i111 ) .* Bx .* By .* Bz;
-endfunction
-
-function [Dx, Dy, Dz, idx, frac] = interp_cube_trilin_grad(x, y, z, val, v)
-  [idx, frac] = cube_idx (x(:), y(:), z(:), v);
-  sval = size (val);
-  i000 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3));
-  i100 = sub2ind (sval, idx(:, 1)+1, idx(:, 2), idx(:, 3));
-  i010 = sub2ind (sval, idx(:, 1), idx(:, 2)+1, idx(:, 3));
-  i001 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3)+1);
-  i101 = sub2ind (sval, idx(:, 1)+1, idx(:, 2), idx(:, 3)+1);
-  i011 = sub2ind (sval, idx(:, 1), idx(:, 2)+1, idx(:, 3)+1);
-  i110 = sub2ind (sval, idx(:, 1)+1, idx(:, 2)+1, idx(:, 3));
-  i111 = sub2ind (sval, idx(:, 1)+1, idx(:, 2)+1, idx(:, 3)+1 );
-  Bx = frac(:, 1);
-  By = frac(:, 2);
-  Bz = frac(:, 3);
-  Dx = ...
-    val( i000 ) .* -1 .* (1 .- By) .* (1 .- Bz) .+ ...
-    val( i100 ) .* (1 .- By) .* (1 .- Bz) .+ ...
-    val( i010 ) .* -1 .* By .* (1 .- Bz) .+ ...
-    val( i001 ) .* -1 .* (1 .- By) .* Bz .+ ...
-    val( i011 ) .* -1 .* By .* Bz .+ ...
-    val( i101 ) .* (1 .- By) .* Bz .+ ...
-    val( i110 ) .* By .* (1 .- Bz) .+ ...
-    val( i111 ) .* By .* Bz;
-  Dy = ...
-    val( i000 ) .* (1 .- Bx) .* -1 .* (1 .- Bz) .+ ...
-    val( i100 ) .* Bx .* -1 .* (1 .- Bz) .+ ...
-    val( i010 ) .* (1 .- Bx) .* (1 .- Bz) .+ ...
-    val( i001 ) .* (1 .- Bx) .* -1 .* Bz .+ ...
-    val( i011 ) .* (1 .- Bx) .* Bz .+ ...
-    val( i101 ) .* Bx .* -1 .* Bz .+ ...
-    val( i110 ) .* Bx .* (1 .- Bz) .+ ...
-    val( i111 ) .* Bx .* Bz;
-  Dz = ...
-    val( i000 ) .* (1 .- Bx) .* (1 .- By) .* -1 .+ ...
-    val( i100 ) .* Bx .* (1 .- By) .* -1 .+ ...
-    val( i010 ) .* (1 .- Bx) .* By .* -1 .+ ...
-    val( i001 ) .* (1 .- Bx) .* (1 .- By) .+ ...
-    val( i011 ) .* (1 .- Bx) .* By + ...
-    val( i101 ) .* Bx .* (1 .- By) .+ ...
-    val( i110 ) .* Bx .* By .* -1 .+ ...
-    val( i111 ) .* Bx .* By;
-endfunction
-
-function [idx, frac] = cube_idx(x, y, z, v)
-  idx = zeros (size (v));
-  frac = zeros (size (v));
-  idx(:, 2) = lookup (x(2:end-1), v(:, 1)) + 1;
-  frac(:, 2) = (v(:, 1) - x(idx(:, 2)) )...
-      ./ (x(idx(:, 2)+1) - x(idx(:, 2)));
-  idx(:, 1) = lookup (y(2:end-1), v(:, 2)) + 1;
-  frac(:, 1) = (v(:, 2) - y(idx(:, 1))) ...
-      ./ (y(idx(:, 1)+1) - y(idx(:, 1)));
-  idx(:, 3) = lookup (z(2:end-1), v(:, 3)) + 1;
-  frac(:, 3) = (v(:, 3) - z(idx(:, 3))) ...
-      ./ (z(idx(:, 3)+1) - z(idx(:, 3)));
-endfunction
\ No newline at end of file
--- a/scripts/plot/__line__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-## Copyright (C) 2005, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {@var{h} =} __line__ (@var{p}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-## __line__ (p, x, y, z)
-## Create line object from x, y, and z with parent p.
-## Return handle to line object.
-
-## Author: jwe
-
-function h = __line__ (p, varargin)
-
-  if (nargin < 1)
-    print_usage ();
-  endif
-
-  nvargs = numel (varargin);
-
-  if (nvargs > 1 && isnumeric (varargin{1}) && isnumeric (varargin{2}))
-    if (nvargs > 2 && isnumeric (varargin{3}))
-      num_data_args = 3;
-    else
-      num_data_args = 2;
-    endif
-  else
-    num_data_args = 0;
-  endif
-
-  if (rem (nvargs - num_data_args, 2) != 0)
-    print_usage ("line");
-  endif
-
-  data_args = {};
-  if (num_data_args > 1)
-    data_args(1:4) = { "xdata", varargin{1}, "ydata", varargin{2} };
-    if (num_data_args == 3)
-      data_args(5:6) = { "zdata", varargin{3} };
-    endif
-  endif
-
-  other_args = {};
-  if (nvargs > num_data_args)
-    other_args = varargin(num_data_args+1:end);
-  endif
-
-  h = __go_line__ (p, data_args{:}, other_args{:});
-
-endfunction
--- a/scripts/plot/__patch__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,316 +0,0 @@
-## Copyright (C) 2007, 2008, 2009 John W. Eaton, Shai Ayal, Kai Habel
-##
-## 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} {[@var{h}, @var{fail}] =} __patch__ (@var{p}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-## __patch__ (p, x, y, c)
-## Create patch object from x and y with color c and parent p.
-## Return handle to patch object.
-
-## Author: Kai Habel
-
-function [h, failed] = __patch__ (p, varargin)
-
-  failed = false;
-
-  if (isstruct (varargin{1}))
-    if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces"))
-      args{1} = "faces";
-      args{2} = getfield(varargin{1}, "faces");
-      args{3} = "vertices";
-      args{4} = getfield(varargin{1}, "vertices");
-      args{5} = "facevertexcdata";
-      if (isfield (varargin{1}, "facevertexcdata"))
-	args{6} = getfield(varargin{1}, "facevertexcdata");
-      else
-	args{6} = [];
-      endif
-      args = [args; varargin(2:end)];
-      args = setdata (args);
-    else
-      failed = true;
-    endif
-  elseif (isnumeric (varargin{1}))
-    if (nargin < 3 || ! isnumeric (varargin{2}))
-      failed = true;
-    else
-      x = varargin{1};
-      y = varargin{2};
-      iarg = 3;
-
-      if (nargin > 3 && ndims (varargin{3}) == 2 && ndims (x) == 2
-	  && size_equal(x, varargin{3}) && !ischar(varargin{3}))
-	z = varargin{3};
-	iarg++;
-      else
-	z = [];
-      endif
-
-      if (isvector (x))
-	x = x(:);
-	y = y(:);
-	z = z(:);
-      endif
-      args{1} = "xdata";
-      args{2} = x;
-      args{3} = "ydata";
-      args{4} = y;
-      args{5} = "zdata";
-      args{6} = z;
-
-      if (isnumeric (varargin{iarg}))
-	c = varargin{iarg};
-	iarg++;
-
-	if (ndims (c) == 3 && size (c, 2) == 1)
-	  c = permute (c, [1, 3, 2]);
-	endif
-
-	if (isvector (c) && numel (c) == columns (x))
-	  if (isnan (c))
-	    args{7} = "facecolor";
-	    args{8} = [1, 1, 1];
-	    args{9} = "cdata";
-	    args{10} = c;
-	  elseif (isnumeric (c))
-	    args{7} = "facecolor";
-	    args{8} = "flat";
-	    args{9} = "cdata";
-	    args{10} = c;
-	  else
-	    error ("patch: color value not valid");
-	  endif
-	elseif (size (c, ndims (c)) == 3)
-	  args{7} = "facecolor";
-	  args{8} = "flat";
-	  args{9} = "cdata";
-	  args{10} = c;
-	else
-	  ## Color Vectors
-	  if (rows (c) != rows (x) || rows (c) != length (y))
-	    error ("patch: size of x, y, and c must be equal")
-	  else
-	    args{7} = "facecolor";
-	    args{8} = "interp";
-	    args{9} = "cdata";
-	    args{10} = [];
-	  endif
-	endif
-      elseif (ischar (varargin{iarg}) && rem (nargin - iarg, 2) != 0)
-	## Assume that any additional argument over an even number is
-	## color string.
-	args{7} = "facecolor";
-	args{8} =  tolower (varargin{iarg});
-	args{9} = "cdata";
-	args{10} = [];
-	iarg++;
-      else
-	args{7} = "facecolor";
-	args{8} = [0, 1, 0];
-	args{9} = "cdata";
-	args{10} = [];
-      endif
-
-      args = [args, varargin(iarg:end)];
-      args = setvertexdata (args);
-    endif
-  else
-    args = varargin;
-    if (any(cellfun (@(x) strcmpi(x,"faces") || strcmpi(x, "vertices"), args)))
-      args = setdata (args);
-    else
-      args = setvertexdata (args);
-    endif
-  endif
-
-  if (!failed)
-    h = __go_patch__ (p, args {:});
-
-    ## Setup listener functions
-    addlistener (h, "xdata", @update_data);
-    addlistener (h, "ydata", @update_data);
-    addlistener (h, "zdata", @update_data);
-    addlistener (h, "cdata", @update_data);
-
-    addlistener (h, "faces", @update_fvc);
-    addlistener (h, "vertices", @update_fvc);
-    addlistener (h, "facevertexcdata", @update_fvc);
-  endif
-endfunction
-
-function args = delfields(args, flds)
-  idx = cellfun (@(x) any (strcmpi (x, flds)), args);
-  idx = idx | [false, idx(1:end-1)];
-  args (idx) = [];
-endfunction
-
-function args = setdata (args)
-  args = delfields (args, {"xdata", "ydata", "zdata", "cdata"});
-  nargs = length (args);
-  idx = find (cellfun (@(x) strcmpi (x, "faces"), args)) + 1;
-  if (idx > nargs)
-    faces = [];
-  else
-    faces = args {idx};
-  endif
-  idx = find (cellfun (@(x) strcmpi (x, "vertices"), args)) + 1;
-  if (idx > nargs)
-    vert = [];
-  else
-    vert = args {idx};
-  endif
-  idx = find (cellfun (@(x) strcmpi (x, "facevertexcdata"), args)) + 1;
-  if (isempty(idx) || idx > nargs)
-    fvc = [];
-  else
-    fvc = args {idx};
-  endif
-  idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args)) + 1;
-  if (isempty(idx) || idx > nargs)
-    if (!isempty (fvc))
-      fc = "flat";
-    else
-      fc = [0, 1, 0];
-    endif
-    args = {"facecolor", fc, args{:}};
-  else
-    fc = args {idx};
-  endif
-
-  nr = size (faces, 2);
-  nc = size (faces, 1);
-  idx = faces .';
-  t1 = isnan (idx);
-  if (any (t1(:)))
-    t2 = find (t1 != t1([2:end,end],:));
-    idx (t1) = idx (t2 (cell2mat (cellfun (@(x) x(1)*ones(1,x(2)),
-		mat2cell ([1 : nc; sum(t1)], 2, ones(1,nc)), 
-					   "UniformOutput", false))));
-  endif
-  x = reshape (vert(:,1)(idx), size (idx));
-  y = reshape (vert(:,2)(idx), size (idx));
-  if (size(vert,2) > 2)
-    z = reshape (vert(:,3)(idx), size (idx));
-  else
-    z = [];
-  endif
-
-  if (ischar (fc) && (strcmpi (fc, "flat") || strcmpi (fc, "interp")))
-    if (size(fvc, 1) == nc || size (fvc, 1) == 1)
-      c = reshape (fvc, [1, size(fvc)]);
-    else
-      if (size(fvc, 2) == 3)
-	c = cat(3, reshape (fvc(idx, 1), size(idx)),
-		reshape (fvc(idx, 2), size(idx)),
-		reshape (fvc(idx, 3), size(idx)));
-      else
-	c = reshape (fvc(idx), size(idx));
-      endif
-    endif
-  else
-    c = [];
-  endif
-  args = {"xdata", x, "ydata", y, "zdata", z, "cdata", c, args{:}};
-endfunction
-
-function args = setvertexdata (args)
-  args = delfields (args, {"vertices", "faces", "facevertexcdata"});
-  nargs = length (args);
-  idx = find (cellfun (@(x) strcmpi (x, "xdata"), args)) + 1;
-  if (idx > nargs)
-    x = [];
-  else
-    x = args {idx};
-  endif
-  idx = find (cellfun (@(x) strcmpi (x, "ydata"), args)) + 1;
-  if (idx > nargs)
-    y = [];
-  else
-    y = args {idx};
-  endif
-  idx = find (cellfun (@(x) strcmpi (x, "zdata"), args)) + 1;
-  if (isempty(idx) || idx > nargs)
-    z = [];
-  else
-    z = args {idx};
-  endif
-  idx = find (cellfun (@(x) strcmpi (x, "cdata"), args)) + 1;
-  if (isempty(idx) || idx > nargs)
-    c = [];
-  else
-    c = args {idx};
-  endif
-  idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args)) + 1;
-  if (isempty(idx) || idx > nargs)
-    if (!isempty (c))
-      fc = "flat";
-    else
-      fc = [0, 1, 0];
-    endif
-    args = {"facecolor", fc, args{:}};
-  else
-    fc = args {idx};
-  endif
-
-  [nr, nc] = size (x);
-  if (!isempty (z))
-    vert = [x(:), y(:), z(:)];
-  else
-    vert = [x(:), y(:)];
-  endif
-  faces = reshape (1:numel(x), rows (x), columns (x));
-  faces = faces';
-
-  if (ischar (fc) && (strcmpi (fc, "flat") || strcmpi (fc, "interp")))
-    if (ndims (c) == 3)
-      fvc = reshape (c, size (c, 1) * size (c, 2), size(c, 3));
-    else
-      fvc = c(:);
-    endif
-  else
-    fvc = [];
-  endif
-
-  args = {"faces", faces, "vertices", vert, "facevertexcdata", fvc, args{:}};
-endfunction
-
-function update_data (h, d)
-  update_handle (h, false);
-endfunction
-
-function update_fvc (h, d)
-  update_handle (h, true);
-endfunction
-
-function update_handle (h, isfv)
-  persistent recursive = false;
-
-  if (! recursive)
-    recursive = true;
-    f = get (h);
-    if (isfvc)
-      set (h, setvertexdata ([fieldnames(f), struct2cell(f)].'(:)){:});
-    else
-      set (h, setdata ([fieldnames(f), struct2cell(f)].'(:)){:});
-    endif
-    recursive = false;
-  endif
-endfunction
--- a/scripts/plot/__plr1__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-## Copyright (C) 1994, 1995, 1996, 1997, 2000, 2005, 2006, 2007, 2009
-##               John W. Eaton
-##
-## 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} {} __plr1__ (@var{h}, @var{theta}, @var{fmt})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plr1__ (h, theta, fmt)
-
-  if (nargin != 3)
-    print_usage ();
-  endif
-
-  [nr, nc] = size (theta);
-  if (nr == 1)
-    theta = theta';
-    tmp = nr;
-    nr = nc;
-    nc = tmp;
-  endif
-  theta_i = imag (theta);
-  if (any (theta_i))
-    rho = theta_i;
-    theta = real (theta);
-  else
-    rho = theta;
-    theta = (1:nr)';
-  endif
-
-  retval = __plr2__ (h, theta, rho, fmt);
-
-endfunction
--- a/scripts/plot/__plr2__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-## Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2005, 2006,
-##               2007, 2009 John W. Eaton
-##
-## 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} {} __plr2__ (@var{h}, @var{theta}, @var{rho}, @var{fmt})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plr2__ (h, theta, rho, fmt)
-
-  if (nargin != 4)
-    print_usage ();
-  endif
-
-  if (any (imag (theta)))
-    theta = real (theta);
-  endif
-
-  if (any (imag (rho)))
-    rho = real (rho);
-  endif
-
-  if (isscalar (theta))
-    if (isscalar (rho))
-      x = rho * cos (theta);
-      y = rho * sin (theta);
-      retval = __plt__ ("polar", h, x, y, fmt);
-    else
-      error ("__plr2__: invalid data for plotting");
-    endif
-  elseif (isvector (theta))
-    if (isvector (rho))
-      if (length (theta) != length (rho))
-        error ("__plr2__: vector lengths must match");
-      endif
-      if (rows (rho) == 1)
-        rho = rho';
-      endif
-      if (rows (theta) == 1)
-        theta = theta';
-      endif
-      x = rho .* cos (theta);
-      y = rho .* sin (theta);
-      retval = __plt__ ("polar", h, x, y, fmt);
-    elseif (ismatrix (rho))
-      [t_nr, t_nc] = size (theta);
-      if (t_nr == 1)
-        theta = theta';
-        tmp = t_nr;
-        t_nr = t_nc;
-        t_nc = tmp;
-      endif
-      [r_nr, r_nc] = size (rho);
-      if (t_nr != r_nr)
-        rho = rho';
-        tmp = r_nr;
-        r_nr = r_nc;
-        r_nc = tmp;
-      endif
-      if (t_nr != r_nr)
-        error ("__plr2__: vector and matrix sizes must match");
-      endif
-      x = diag (cos (theta)) * rho;
-      y = diag (sin (theta)) * rho;
-      retval = __plt__ ("polar", h, x, y, fmt);
-    else
-      error ("__plr2__: invalid data for plotting");
-    endif
-  elseif (ismatrix (theta))
-    if (isvector (rho))
-      [r_nr, r_nc] = size (rho);
-      if (r_nr == 1)
-        rho = rho';
-        tmp = r_nr;
-        r_nr = r_nc;
-        r_nc = tmp;
-      endif
-      [t_nr, t_nc] = size (theta);
-      if (r_nr != t_nr)
-        theta = theta';
-        tmp = t_nr;
-        t_nr = t_nc;
-        t_nc = tmp;
-      endif
-      if (r_nr != t_nr)
-        error ("__plr2__: vector and matrix sizes must match");
-      endif
-      diag_r = diag (rho);
-      x = diag_r * cos (theta);
-      y = diag_r * sin (theta);
-      retval = __plt__ ("polar", h, x, y, fmt);
-    elseif (ismatrix (rho))
-      if (! size_equal (rho, theta))
-        error ("__plr2__: matrix dimensions must match");
-      endif
-      x = rho .* cos (theta);
-      y = rho .* sin (theta);
-      retval = __plt__ ("polar", h, x, y, fmt);
-    else
-      error ("__plr2__: invalid data for plotting");
-    endif
-  else
-    error ("__plr2__: invalid data for plotting");
-  endif
-
-endfunction
--- a/scripts/plot/__plt1__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-## Copyright (C) 1994, 1995, 1996, 1997, 2000, 2005, 2006, 2007, 2009
-##               John W. Eaton
-##
-## 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} {} __plt1__ (@var{h}, @var{x1}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt1__ (h, x1, options, properties)
-
-  if (nargin < 2 || nargin > 4)
-    print_usage ();
-  endif
-
-  if (nargin < 3 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 4)
-    properties = {};
-  endif
-
-  if (! isstruct (options))
-    error ("__plt1__: options must be a struct array");
-  endif
-
-  [nr, nc] = size (x1);
-  if (nr == 1)
-    x1 = x1.';
-    tmp = nr;
-    nr = nc;
-    nc = tmp;
-  endif
-  x1_i = imag (x1);
-  if (any (any (x1_i)))
-    x2 = x1_i;
-    x1 = real (x1);
-  else
-    x2 = x1;
-    x1 = (1:nr)';
-  endif
-
-  retval = __plt2__ (h, x1, x2, options, properties);
-
-endfunction
--- a/scripts/plot/__plt2__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-## Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2005, 2006, 2007,
-##               2008, 2009 John W. Eaton
-##
-## 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} {} __plt2__ (@var{h}, @var{x1}, @var{x2}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt2__ (h, x1, x2, options, properties)
-
-  if (nargin < 3 || nargin > 5)
-    print_usage ();
-  endif
-
-  if (nargin < 4 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 5)
-    properties = {};
-  endif
-
-  if (! isstruct (options))
-    error ("__plt1__: options must be a struct array");
-  endif
-
-  if (any (any (imag (x1))))
-    x1 = real (x1);
-  endif
-
-  if (any (any (imag (x2))))
-    x2 = real (x2);
-  endif
-
-  h_set = false;
-  if (isempty (x1) && isempty (x2))
-    retval = zeros (0, 1);
-  elseif (isscalar (x1))
-    if (isscalar (x2))
-      retval = __plt2ss__ (h, x1, x2, options, properties);
-    elseif (isvector (x2))
-      retval = __plt2sv__ (h, x1, x2, options, properties);
-    else
-      error ("__plt2__: invalid data for plotting");
-    endif
-  elseif (isvector (x1))
-    if (isscalar (x2))
-      retval = __plt2vs__ (h, x1, x2, options, properties);
-    elseif (isvector (x2))
-      retval = __plt2vv__ (h, x1, x2, options, properties);
-    elseif (ismatrix (x2))
-      retval = __plt2vm__ (h, x1, x2, options, properties);
-    else
-      error ("__plt2__: invalid data for plotting");
-    endif
-  elseif (ismatrix (x1))
-    if (isvector (x2))
-      retval = __plt2mv__ (h, x1, x2, options, properties);
-    elseif (ismatrix (x2))
-      retval = __plt2mm__ (h, x1, x2, options, properties);
-    else
-      error ("__plt2__: invalid data for plotting");
-    endif
-  else
-    error ("__plt2__: invalid data for plotting");
-  endif
-
-endfunction
--- a/scripts/plot/__plt2mm__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2003, 2005,
-##               2006, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __plt2mm__ (@var{h}, @var{x}, @var{y}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt2mm__ (h, x, y, options, properties)
-
-  if (nargin < 3 || nargin > 5)
-    print_usage ();
-  endif
-
-  if (nargin < 4 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 5)
-    properties = {};
-  endif
-
-  [x_nr, x_nc] = size (x);
-  [y_nr, y_nc] = size (y);
-
-  k = 1;
-  if (x_nr == y_nr && x_nc == y_nc)
-    if (x_nc > 0)
-      if (numel (options) == 1)
-	options = repmat (options(:), x_nc, 1);
-      endif
-      retval = zeros (x_nc, 1);
-      for i = 1:x_nc
-	tkey = options(i).key;
-	if (! isempty (tkey))
-	  set (h, "key", "on");
-	endif
-	color = options(i).color;
-	if (isempty (color))
-	  color = __next_line_color__ ();
-	endif
-
-	retval(i) = line (x(:,i), y(:,i), "keylabel", tkey, "color", color,
-			  "linestyle", options(i).linestyle,
-			  "marker", options(i).marker, properties{:});
-      endfor
-    else
-      error ("__plt2mm__: arguments must be a matrices");
-    endif
-  else
-    error ("__plt2mm__: matrix dimensions must match");
-  endif
-
-endfunction
--- a/scripts/plot/__plt2mv__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2003, 2005,
-##               2006, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __plt2mv__ (@var{h}, @var{x}, @var{y}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt2mv__ (h, x, y, options, properties)
-
-  if (nargin < 3 || nargin > 5)
-    print_usage ();
-  endif
-
-  if (nargin < 4 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 5)
-    properties = {};
-  endif
-
-  [x_nr, x_nc] = size (x);
-  [y_nr, y_nc] = size (y);
-
-  if (y_nr == 1)
-    y = y';
-    tmp = y_nr;
-    y_nr = y_nc;
-    y_nc = tmp;
-  endif
-
-  if (x_nr == y_nr)
-    1;
-  elseif (x_nc == y_nr)
-    x = x';
-    tmp = x_nr;
-    x_nr = x_nc;
-    x_nc = tmp;
-  else
-    error ("__plt2mv__: matrix dimensions must match");
-  endif
-
-  if (x_nc > 0)
-    if (numel (options) == 1)
-      options = repmat (options(:), x_nc, 1);
-    endif
-    retval = zeros (x_nc, 1);
-    for i = 1:x_nc
-      tkey = options(i).key;
-      if (! isempty (tkey))
-	set (h, "key", "on");
-      endif
-      color = options(i).color;
-      if (isempty (color))
-	color = __next_line_color__ ();
-      endif
-
-      retval(i) = line (x(:,i), y, "keylabel", tkey, "color", color,
-			"linestyle", options(i).linestyle,
-			"marker", options(i).marker, properties{:});
-    endfor
-  else
-    error ("__plt2mv__: arguments must be a matrices");
-  endif
-
-endfunction
--- a/scripts/plot/__plt2ss__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2003, 2005,
-##               2006, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __plt2ss__ (@var{h}, @var{x}, @var{y}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt2ss__ (h, x, y, options, properties)
-
-  if (nargin < 3 || nargin > 5)
-    print_usage ();
-  endif
-
-  if (nargin < 4 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 5)
-    properties = {};
-  endif
-
-  if (numel (options) > 1)
-    options = options(1);
-  endif
-
-  [x_nr, x_nc] = size (x);
-  [y_nr, y_nc] = size (y);
-
-  if (x_nr == 1 && x_nr == y_nr && x_nc == 1 && x_nc == y_nc)
-    key = options.key;
-    if (! isempty (key))
-      set (h, "key", "on");
-    endif
-    color = options.color;
-    if (isempty (color))
-      color = __next_line_color__ ();
-    endif
-
-    retval = line (x, y, "keylabel", key, "color", color,
-		   "linestyle", options.linestyle,
-		   "marker", options.marker, properties{:});
-  else
-    error ("__plt2ss__: arguments must be scalars");
-  endif
-
-endfunction
--- a/scripts/plot/__plt2sv__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2003, 2005,
-##               2006, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __plt2sv__ (@var{h}, @var{x}, @var{y}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt2sv__ (h, x, y, options, properties)
-
-  if (nargin < 3 || nargin > 5)
-    print_usage ();
-  endif
-
-  if (nargin < 4 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 5)
-    properties = {};
-  endif
-
-  if (isscalar (x) && isvector (y))
-    len = numel (y);
-    if (numel (options) == 1)
-      options = repmat (options(:), len, 1);
-    endif
-    retval = zeros (len, 1);
-    for i = 1:len
-      tkey = options(i).key;
-      if (! isempty (tkey))
-	set (h, "key", "on");
-      endif
-      color = options(i).color;
-      if (isempty (color))
-	color = __next_line_color__ ();
-      endif
-
-      retval(i) = line (x, y(i), "keylabel", tkey, "color", color,
-			"linestyle", options(i).linestyle,
-			"marker", options(i).marker, properties{:});
-    endfor
-  else
-    error ("__plt2sv__: first arg must be scalar, second arg must be vector");
-  endif
-
-endfunction
--- a/scripts/plot/__plt2vm__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2003, 2004,
-##               2005, 2006, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __plt2vm__ (@var{h}, @var{x}, @var{y}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt2vm__ (h, x, y, options, properties)
-
-  if (nargin < 3 || nargin > 5)
-    print_usage ();
-  endif
-
-  if (nargin < 4 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 5)
-    properties = {};
-  endif
-
-  [x_nr, x_nc] = size (x);
-  [y_nr, y_nc] = size (y);
-
-  if (x_nr == 1)
-    x = x';
-    tmp = x_nr;
-    x_nr = x_nc;
-    x_nc = tmp;
-  endif
-
-  if (x_nr == y_nr)
-    1;
-  elseif (x_nr == y_nc)
-    y = y';
-    tmp = y_nr;
-    y_nr = y_nc;
-    y_nc = tmp;
-  else
-    error ("__plt2vm__: matrix dimensions must match");
-  endif
-
-  if (y_nc > 0)
-    if (numel (options) == 1)
-      options = repmat (options(:), y_nc, 1);
-    endif
-    retval = zeros (y_nc, 1);
-    for i = 1:y_nc
-      tkey = options(i).key;
-      if (! isempty (tkey))
-	set (h, "key", "on");
-      endif
-      color = options(i).color;
-      if (isempty (color))
-	color = __next_line_color__ ();
-      endif
-
-      retval(i) = line (x, y(:,i), "keylabel", tkey, "color", color,
-			"linestyle", options(i).linestyle,
-			"marker", options(i).marker, properties{:});
-    endfor
-  else
-    error ("__plt2vm__: arguments must be a matrices");
-  endif
-
-endfunction
--- a/scripts/plot/__plt2vs__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2003, 2005,
-##               2006, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __plt2vs__ (@var{h}, @var{x}, @var{y}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt2vs__ (h, x, y, options, properties)
-
-  if (nargin < 3 || nargin > 5)
-    print_usage ();
-  endif
-
-  if (nargin < 4 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 5)
-    properties = {};
-  endif
-
-  if (isvector (x) && isscalar (y))
-    len = numel (x);
-    if (numel (options) == 1)
-      options = repmat (options(:), len, 1);
-    endif
-    retval = zeros (len, 1);
-    for i = 1:len
-      tkey = options(i).key;
-      if (! isempty (tkey))
-	set (h, "key", "on");
-      endif
-      color = options(i).color;
-      if (isempty (color))
-	color = __next_line_color__ ();
-      endif
-
-      retval(i) = line (x(i), y, "keylabel", tkey, "color", color,
-			"linestyle", options(i).linestyle,
-			"marker", options(i).marker, properties{:});
-    endfor
-  else
-    error ("__plt2vs__: first arg must be vector, second arg must be scalar");
-  endif
-
-endfunction
--- a/scripts/plot/__plt2vv__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2003, 2005,
-##               2006, 2007, 2008, 2009 John W. Eaton
-##
-## 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} {} __plt2vv__ (@var{h}, @var{x}, @var{y}, @var{options}, @var{properties})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt2vv__ (h, x, y, options, properties)
-
-  if (nargin < 3 || nargin > 5)
-    print_usage ();
-  endif
-
-  if (nargin < 4 || isempty (options))
-    options = __default_plot_options__ ();
-  endif
-
-  if (nargin < 5)
-    properties = {};
-  endif
-
-  if (numel (options) > 1)
-    options = options(1);
-  endif
-
-  [x_nr, x_nc] = size (x);
-  [y_nr, y_nc] = size (y);
-
-  if (x_nr == 1)
-    x = x';
-    tmp = x_nr;
-    x_nr = x_nc;
-    x_nc = tmp;
-  endif
-
-  if (y_nr == 1)
-    y = y';
-    tmp = y_nr;
-    y_nr = y_nc;
-    y_nc = tmp;
-  endif
-
-  if (x_nr == y_nr)
-    key = options.key;
-    if (! isempty (key))
-      set (h, "key", "on");
-    endif
-    color = options.color;
-    if (isempty (color))
-      color = __next_line_color__ ();
-    endif
-
-    retval = line (x, y, "keylabel", key, "color", color,
-	      "linestyle", options.linestyle,
-	      "marker", options.marker, properties{:});
-  else
-    error ("__plt2vv__: vector lengths must match");
-  endif
-
-endfunction
--- a/scripts/plot/__plt__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2004,
-##               2005, 2006, 2007, 2009 John W. Eaton
-##
-## 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} {} __plt__ (@var{caller}, @var{h}, @var{varargin})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function retval = __plt__ (caller, h, varargin)
-
-  nargs = nargin - 2;
-
-  if (nargs > 0)
-
-    k = 1;
-
-    x_set = false;
-    y_set = false;
-    property_set = false;
-    properties = {};
-
-    ## Gather arguments, decode format, gather plot strings, and plot lines.
-
-    retval = [];
-
-    while (nargs > 0 || x_set)
-
-      if (nargs == 0)
-	## Force the last plot when input variables run out.
-	next_cell = {};
-	next_arg = {""};
-      else
-	next_cell = varargin(k);
-	next_arg = varargin{k++};
-      endif
-
-      nargs--;
-
-      if (ischar (next_arg) || iscellstr (next_arg))
-	if (x_set)
-	  [options, valid] = __pltopt__ (caller, next_arg, false);
-	  if (! valid)
-	    if (nargs == 0)
-	      error ("%s: properties must appear followed by a value", caller);
-	    endif
-	    properties = [properties, [next_cell, varargin(k++)]];
-	    nargs--;
-	    continue;
-	  else
-	    while (nargs > 0 && ischar (varargin{k}))
-	      if (nargs < 2)
-		error ("%s: properties must appear followed by a value",
-		       caller);
-	      endif
-	      properties = [properties, varargin(k:k+1)];
-	      k += 2;
-	      nargs -= 2;
-	    endwhile
-	  endif
-	  if (y_set)
-	    tmp = __plt2__ (h, x, y, options, properties);
-	    properties = {};
-	    retval = [retval; tmp];
-	  else
-	    tmp = __plt1__ (h, x, options, properties);
-	    properties = {};
-	    retval = [retval; tmp];
-	  endif
-	  x_set = false;
-	  y_set = false;
-	else
-	  error ("plot: no data to plot");
-	endif
-      elseif (x_set)
-	if (y_set)
-	  options = __pltopt__ (caller, {""});
-	  tmp = __plt2__ (h, x, y, options, properties);
-	  retval = [retval; tmp];
-	  x = next_arg;
-	  y_set = false;
-	  properties = {};
-	else
-	  y = next_arg;
-	  y_set = true;
-	endif
-      else
-	x = next_arg;
-	x_set = true;
-      endif
-
-    endwhile
-
-  else
-    msg = sprintf ("%s (y)\n", caller);
-    msg = sprintf ("%s       %s (x, y, ...)\n", msg, caller);
-    msg = sprintf ("%s       %s (x, y, fmt, ...)", msg, caller);
-    msg = sprintf ("%s       %s (x, y, property, value, ...)", msg, caller);
-    usage (msg);
-  endif
-
-endfunction
-  
--- a/scripts/plot/__pltopt1__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-## Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005,
-##               2006, 2007, 2009 John W. Eaton
-##
-## 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} {[@var{options}, @var{valid}] =} __pltopt1__ (@var{caller}, @var{opt}, @var{err_on_invalid})
-## Undocumented internal function.
-## @end deftypefn
-
-## Really decode plot option strings.
-
-## Author: Rick Niles <niles@axp745.gsfc.nasa.gov>
-## Adapted-By: jwe
-## Maintainer: jwe
-
-function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid)
-
-  options = __default_plot_options__ ();
-  valid = true;
-
-  more_opts = 1;
-
-  if (nargin != 2 && nargin != 3)
-    print_usage ();
-  endif
-
-  if (! ischar (opt))
-    return;
-  endif
-
-  have_linestyle = false;
-  have_marker = false;
-
-  ## If called by __errplot__, extract the linestyle before proceeding.
-  if (strcmp (caller,"__errplot__"))
-    if (strncmp (opt, "#~>", 3))
-      n = 3;
-    elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2))
-      n = 2;
-    elseif (strncmp (opt, "~", 1) || strncmp (opt, ">", 1) 
-	    || strncmp (opt, "#", 1))
-      n = 1;
-    endif
-      options.linestyle = opt(1:n);
-      opt(1:n) = [];
-      have_linestyle = true;
-  endif
-
-  while (! isempty (opt))
-    if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2))
-      options.linestyle = opt(1:2);
-      have_linestyle = true;
-      n = 2;
-    else
-      topt = opt(1);
-      n = 1;
-      if (topt == "-" || topt == ":")
-	have_linestyle = true;
-	options.linestyle = topt;
-      elseif (topt == "+" || topt == "o" || topt == "*"
-	      || topt == "." || topt == "x" || topt == "s"
-	      || topt == "d" || topt == "^" || topt == "v"
-	      || topt == ">" || topt == "<" || topt == "p"
-	      || topt == "h" || topt == "@")
-	have_marker = true;
-	## Backward compatibility.  Leave undocumented.
-	if (topt == "@")
-	  topt = "+";
-	endif
-	options.marker = topt;
-### Numeric color specs for backward compatibility.  Leave undocumented.
-      elseif (topt == "k" || topt == "0")
-	options.color = [0, 0, 0];
-      elseif (topt == "r" || topt == "1")
-	options.color = [1, 0, 0];
-      elseif (topt == "g" || topt == "2")
-	options.color = [0, 1, 0];
-      elseif (topt == "b" || topt == "3")
-	options.color = [0, 0, 1];
-      elseif (topt == "y")
-	options.color = [1, 1, 0];
-      elseif (topt == "m" || topt == "4")
-	options.color = [1, 0, 1];
-      elseif (topt == "c" || topt == "5")
-	options.color = [0, 1, 1];
-      elseif (topt == "w" || topt == "6")
-	options.color = [1, 1, 1];
-      elseif (isspace (topt))
-	## Do nothing.
-      elseif (topt == ";")
-	t = index (opt(2:end), ";");
-	if (t)
-	  options.key = undo_string_escapes (opt(2:t));
-	  n = t+1;
-	else
-	  if (err_on_invalid)
-            error ("%s: unfinished key label", caller);
-	  else
-	    valid = false;
-	    options = __default_plot_options__ ();
-	    return;
-	  endif
-        endif
-      else
-	if (err_on_invalid)
-	  error ("%s: unrecognized format character: `%s'", caller, topt);
-	else
-	  valid = false;
-	  options = __default_plot_options__ ();
-	  return;
-	endif
-      endif
-    endif
-    opt(1:n) = [];
-  endwhile
-
-  if (have_marker && ! have_linestyle)
-    options.linestyle = "none";
-  endif
-
-endfunction
--- a/scripts/plot/__pltopt__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-## Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2005,
-##               2006, 2007, 2009 John W. Eaton
-##
-## 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} {} __pltopt__ (@var{caller}, @var{opt})
-## Undocumented internal function.
-## @end deftypefn
-
-## @deftypefn {Function File} {} __pltopt__ (@var{caller}, @var{opt})
-##
-## Decode plot option strings.
-##
-## @var{opt} can currently be some combination of the following:
-##
-## @table @code
-## @item "-"
-## For solid linestyle (default).
-##
-## @item "--"
-## For dashed line style.
-##
-## @item "-."
-## For linespoints plot style.
-##
-## @item ":"
-## For dots plot style.
-##
-## @item "r"
-## Red line color.
-##
-## @item "g"
-## Green line color.
-##
-## @item "b"
-## Blue line color.
-##
-## @item "c"
-## Cyan line color.
-##
-## @item "m"
-## Magenta line color.
-##
-## @item "y"
-## Yellow line color.
-##
-## @item "k"
-## Black line color.
-##
-## @item "w"
-## White line color.
-##
-## @item ";title;"
-## Here @code{"title"} is the label for the key.
-##
-## @item "+"
-## @itemx "o"
-## @itemx "*"
-## @itemx "."
-## @itemx "x"
-## @itemx "s"
-## @itemx "d"
-## @itemx "^"
-## @itemx "v"
-## @itemx ">"
-## @itemx "<"
-## @itemx "p"
-## @itemx "h"
-## Used in combination with the points or linespoints styles, set the point
-## style.
-## @end table
-##
-## The legend may be fixed to include the name of the variable
-## plotted in some future version of Octave.
-
-## Author: jwe
-
-function [options, valid] = __pltopt__ (caller, opt, err_on_invalid)
-
-  valid = true;
-  options =  __default_plot_options__ ();
-
-  if ((nargin == 2 || nargin == 3) && (nargout == 1 || nargout == 2))
-    if (nargin == 2)
-      err_on_invalid = true;
-    endif
-    if (ischar (opt))
-      nel = rows (opt);
-    elseif (iscellstr (opt))
-      nel = numel (opt);
-    else
-      error ("__pltopt__: expecting argument to be character string or cell array of character strings");
-    endif
-    if (ischar (opt))
-      opt = cellstr (opt);
-    endif
-    for i = nel:-1:1
-      [options(i), valid] = __pltopt1__ (caller, opt{i}, err_on_invalid);
-      if (! err_on_invalid && ! valid)
-	return;
-      endif
-    endfor
-  else
-    print_usage ();
-  endif
-
-endfunction
--- a/scripts/plot/__quiver__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,421 +0,0 @@
-## Copyright (C) 2007, 2008, 2009 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} {@var{hg} =} __quiver__ (@dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-function hg = __quiver__ (varargin)
-
-  h = varargin{1};
-  is3d = varargin{2};
-
-  autoscale = 0.9;
-  arrowsize = 0.2;
-
-  firstnonnumeric = Inf;
-  for i = 3:nargin
-    if (! isnumeric (varargin{i}))
-      firstnonnumeric = i;
-      break;
-    endif
-  endfor
-
-  ioff = 3;
-  if (nargin < (6 + is3d) || firstnonnumeric < (6 + is3d))
-    u = varargin{ioff++};
-    v = varargin{ioff++};
-    if (is3d)
-      w = varargin{ioff++}
-      [x, y, z] = meshgrid (1:size(u,2), 1:size(u,1), 1:max(size(w)));
-    else
-      [x, y] = meshgrid (1:size(u,2), 1:size(u,1));
-    endif
-    if (nargin >= ioff && isnumeric (varargin{ioff})
-	&& isscalar (varargin{ioff}))
-      autoscale = varargin{ioff++};
-    endif
-  else
-    x = varargin{ioff++};
-    y = varargin{ioff++};
-    if (is3d)
-      z = varargin{ioff++};
-    endif
-    u = varargin{ioff++};
-    v = varargin{ioff++}; 
-    if (is3d)
-      w = varargin{ioff++};
-      if (isvector (x) && isvector (y) && isvector (z)
-	  && (! isvector (u) || ! isvector (v) || ! isvector(w)))
-	[x, y, z] = meshgrid (x, y, z);
-      endif
-    else
-      if (isvector (x) && isvector (y) && (! isvector (u) || ! isvector (v)))
-	[x, y] = meshgrid (x, y);
-      endif
-    endif
-    if (nargin >= ioff && isnumeric (varargin{ioff})
-	&& isscalar (varargin{ioff}))
-      autoscale = varargin{ioff++};
-    endif
-  endif
-
-  have_filled = false;
-  have_line_spec = false;
-  args = {};
-  while (ioff <= nargin)
-    arg = varargin{ioff++};
-    if (ischar (arg) && strncmpi (arg, "filled", 6))
-      have_filled = true;
-    elseif ((ischar (arg) || iscell (arg))
-	    && ! have_line_spec)
-      [linespec, valid] = __pltopt__ ("quiver", arg, false);
-      if (valid)
-	have_line_spec = true;
-	if (strncmp (linespec.linestyle, "none", 4))
-	  linespec.linestyle = "-";
-	endif
-      else
-	args {end + 1} = arg;
-        if (ioff <= nargin)
-          args {end + 1} = varargin{ioff++};
-        endif
-      endif
-    else
-      args {end + 1} = arg;
-      if (ioff <= nargin)
-        args {end + 1} = varargin{ioff++};
-      endif
-    endif
-  endwhile
-
-  if (autoscale && numel (u) > 1)
-    ## Scale the arrows to fit in the grid
-    dx = (max(x(:)) - min(x(:))) ./ size (x, 2);
-    dy = (max(y(:)) - min(y(:))) ./ size (y, 1);
-    if (is3d)
-      ## What should this be divided by? The below seems right
-      dz = (max(z(:)) - min(z(:))) ./ max (size (z));
-      len = max (sqrt (u(:).^2 + dy(:).^2) + dz(:).^2);
-    else
-      len = max (sqrt (u(:).^2 + dy(:).^2));
-      dz = 0;
-    endif
-    if (len > 0)
-      s = 2 * autoscale / sqrt (2) * sqrt (dx.^2 + dy.^2 + dz.^2) / len; 
-      uu = s * u;
-      vv = s * v;
-      if (is3d)
-	ww = s*w;
-      endif
-    endif
-  else
-    uu = u;
-    vv = v;
-    if (is3d)
-      ww = w;
-    endif
-  endif
-
-  hstate = get (h, "nextplot");
-  unwind_protect
-    hg = hggroup ();
-    if (is3d)
-      args = __add_datasource__ ("quiver3", hg, 
-				 {"x", "y", "z", "u", "v", "w"}, args{:});
-    else
-      args = __add_datasource__ ("quiver", hg, 
-				 {"x", "y", "z", "u", "v", "w"}, args{:});
-    endif
-    hold on;
-
-    addproperty ("xdata", hg, "data", x);
-    addproperty ("ydata", hg, "data", y);
-
-    addproperty ("udata", hg, "data", u);
-    addproperty ("vdata", hg, "data", v);
-    if (is3d)
-      addproperty ("zdata", hg, "data", z);
-      addproperty ("wdata", hg, "data", w);
-    else
-      addproperty ("zdata", hg, "data", []);
-      addproperty ("wdata", hg, "data", []);
-    endif
-
-    addlistener (hg, "xdata", @update_data);
-    addlistener (hg, "ydata", @update_data);
-    addlistener (hg, "zdata", @update_data);
-    addlistener (hg, "udata", @update_data);
-    addlistener (hg, "vdata", @update_data);
-    addlistener (hg, "wdata", @update_data);
-
-    x = x(:);
-    y = y(:);
-    xend = x + uu(:);
-    yend = y + vv(:);
-    if (is3d)
-      z = z(:);
-      zend = z + ww(:);
-    endif
-
-    if (have_line_spec)
-      if (is3d)
-	h1 = plot3 ([x.'; xend.'; NaN(1, length (x))](:),
-		    [y.'; yend.'; NaN(1, length (y))](:),
-		    [z.'; zend.'; NaN(1, length (z))](:),
-		    "linestyle", linespec.linestyle, 
-		    "color", linespec.color, "parent", hg);
-      else
-	h1 = plot ([x.'; xend.'; NaN(1, length (x))](:),
-		   [y.'; yend.'; NaN(1, length (y))](:),
-		   "linestyle", linespec.linestyle, 
-		    "color", linespec.color, "parent", hg);
-      endif
-    else
-      if (is3d)
-	h1 = plot3 ([x.'; xend.'; NaN(1, length (x))](:),
-		    [y.'; yend.'; NaN(1, length (y))](:),
-		    [z.'; zend.'; NaN(1, length (z))](:),
-		    "parent", hg);
-      else
-	h1 = plot ([x.'; xend.'; NaN(1, length (x))](:),
-		   [y.'; yend.'; NaN(1, length (y))](:),
-		   "parent", hg);
-      endif
-    endif
-
-    xtmp = x + uu(:) .* (1 - arrowsize);
-    ytmp = y + vv(:) .* (1 - arrowsize);
-    xarrw1 = xtmp + (y - yend) * arrowsize / 3;
-    xarrw2 = xtmp - (y - yend) * arrowsize / 3;
-    yarrw1 = ytmp - (x - xend) * arrowsize / 3;
-    yarrw2 = ytmp + (x - xend) * arrowsize / 3;
-    if (is3d)
-      zarrw1 = zarrw2 = zend - ww(:) * arrowsize;
-    endif
-
-    if (have_line_spec)
-      if (isfield (linespec, "marker") && 
-	! strncmp (linespec.marker, "none", 4))
-	if (is3d)
-	  h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
-		      [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
-		      [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:),
-		      "linestyle", "none", "parent", hg);
-	else
-	  h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
-		     [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
-		     "linestyle", "none", "parent", hg);
-	endif
-      else
-	if (is3d)
-	  h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
-		      [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
-		      [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:),
-		      "linestyle", linespec.linestyle,
-		      "color", linespec.color, "parent", hg);
-	else
-	  h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
-		     [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
-		     "linestyle", linespec.linestyle,
-		      "color", linespec.color, "parent", hg);
-	endif
-      endif
-    elseif (is3d)
-      h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
-		  [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
-		  [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:),
-		  "parent", hg);
-    else
-      h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
-		 [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
-		 "parent", hg);
-    endif
-
-    if (! have_line_spec
-	|| (isfield (linespec, "marker")
-	    && strncmp (linespec.marker, "none", 4)))
-      if (is3d)
-	h3 = plot3 (x, y, z, "linestyle", "none", "marker", "none", 
-		    "parent", hg);
-      else
-	h3 = plot (x, y, "linestyle", "none", "marker", "none", "parent", hg);
-      endif
-    else
-      if (is3d)
-	h3 = plot3 (x, y, z, "linestyle", "none", "marker", linespec.marker,
-		    "parent", hg);
-      else
-
-	h3 = plot (x, y, "linestyle", "none", "marker", linespec.marker,
-		   "parent", hg);
-      endif
-    endif
-    if (have_filled)
-      ## FIXME gnuplot doesn't respect the markerfacecolor field
-      set (h3, "markerfacecolor", get (h1, "color")); 
-    endif
-
-    ## Set up the hggroup properties and listeners
-    if (autoscale)
-      addproperty ("autoscale", hg, "radio", "{on}|off", "on");
-      addproperty ("autoscalefactor", hg, "data", autoscale)
-    else
-      addproperty ("autoscale", hg, "radio", "{on}|off", "off");
-      addproperty ("autoscalefactor", hg, "data", 1.0)
-    endif
-    addlistener (hg, "autoscale", @update_data)
-    addlistener (hg, "autoscalefactor", @update_data)
-
-    addproperty ("maxheadsize", hg, "data", arrowsize)
-    addlistener (hg, "maxheadsize", @update_data);
-
-    addproperty ("showarrowhead", hg, "radio", "{on}|off", "on");
-    addlistener (hg, "showarrowhead", @update_props);
-
-    addproperty ("color", hg, "linecolor", get (h1, "color"));
-    addproperty ("linewidth", hg, "linelinewidth", get (h1, "linewidth"));
-    addproperty ("linestyle", hg, "linelinestyle", get (h1, "linestyle"));
-    addproperty ("marker", hg, "linemarker", get (h3, "marker"));
-    addproperty ("markerfacecolor", hg, "linemarkerfacecolor",
-		 get (h3, "markerfacecolor"));
-    addproperty ("markersize", hg, "linemarkersize", get (h3, "markersize"));
-
-    addlistener (hg, "color", @update_props);
-    addlistener (hg, "linewidth", @update_props); 
-    addlistener (hg, "linestyle", @update_props); 
-    addlistener (hg, "marker", @update_props); 
-    addlistener (hg, "markerfacecolor", @update_props); 
-    addlistener (hg, "markersize", @update_props);
-
-    if (! isempty (args))
-      set (hg, args{:});
-    endif
-  unwind_protect_cleanup
-    set (h, "nextplot", hstate);
-  end_unwind_protect
-
-endfunction
-
-function update_data (h, d)
-  x = get (h, "xdata");
-  y = get (h, "ydata");
-  z = get (h, "zdata");
-
-  u = get (h, "udata");
-  v = get (h, "vdata");
-  w = get (h, "wdata");
-
-  s = get (h, "autoscalefactor");
-  arrowsize = get (h, "maxheadsize");
-
-  kids = get (h, "children");
-
-  if (isempty (z) || isempty (w))
-    is3d = false;
-  else
-    is3d = true;
-  endif
-
-  if (strcmpi (get (h, "autoscale"), "on") && s != 0)
-    ## Scale the arrows to fit in the grid
-    dx = (max(x(:)) - min(x(:))) ./ size (x, 2);
-    dy = (max(y(:)) - min(y(:))) ./ size (y, 1);
-    if (is3d)
-      ## What should this be divided by? The below seems right
-      dz = (max(z(:)) - min(z(:))) ./ max (size (z));
-      len = max (sqrt (u(:).^2 + dy(:).^2) + dz(:).^2);
-    else
-      len = max (sqrt (u(:).^2 + dy(:).^2));
-      dz = 0;
-    endif
-    if (len > 0)
-      s = 2 * s / sqrt (2) * sqrt (dx.^2 + dy.^2 + dz.^2) / len; 
-      u = s * u;
-      v = s * v;
-      if (is3d)
-	w = s*w;
-      endif
-    endif
-  endif
-
-  x = x(:);
-  y = y(:);
-  xend = x + u(:);
-  yend = y + v(:);
-  if (is3d)
-    z = z(:);
-    zend = z + w(:);
-  endif
-
-  set (kids (3), "xdata", [x.'; xend.'; NaN(1, length (x))](:));
-  set (kids (3), "ydata", [y.'; yend.'; NaN(1, length (y))](:));
-  if (is3d)
-    set (kids (3), "zdata", [z.'; zend.'; NaN(1, length (z))](:));
-  endif
-
-  xtmp = x + u(:) .* (1 - arrowsize);
-  ytmp = y + v(:) .* (1 - arrowsize);
-  xarrw1 = xtmp + (y - yend) * arrowsize / 3;
-  xarrw2 = xtmp - (y - yend) * arrowsize / 3;
-  yarrw1 = ytmp - (x - xend) * arrowsize / 3;
-  yarrw2 = ytmp + (x - xend) * arrowsize / 3;
-  if (is3d)
-    zarrw1 = zarrw2 = zend - w(:) * arrowsize;
-  endif
-
-  set (kids (2), "xdata", [x.'; xend.'; NaN(1, length (x))](:));
-  set (kids (2), "ydata", [y.'; yend.'; NaN(1, length (y))](:));
-  if (is3d)
-    set (kids (2), "zdata", [z.'; zend.'; NaN(1, length (z))](:));
-  endif
-
-  set (kids (2), "xdata", [xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:));
-  set (kids (2), "ydata", [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:));
-  if (is3d)
-    set (kids (2), "zdata", [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:));
-  endif
-
-  set (kids (1), "xdata", x);
-  set (kids (1), "ydata", y);
-  if (is3d)
-    set (kids (1), "zdata", z);
-  endif
-
-endfunction
-
-function update_props (h, d)
-  kids = get (h, "children");
-
-  set (kids(3), "color", get (h, "color"), 
-       "linewidth", get (h, "linewidth"),
-       "linestyle", get (h, "linestyle"));
-  set (kids(2), "color", get (h, "color"), 
-       "linewidth", get (h, "linewidth"),
-       "linestyle", get (h, "linestyle"));
-  if (strcmpi (get (h, "showarrowhead"), "on"))
-    set (kids (2), "visible", "on");
-  else
-    set (kids (2), "visible", "off");
-  endif
-  set (kids(1), "color", get (h, "color"), 
-       "marker", get (h, "marker"),
-       "markerfacecolor", get (h, "markerfacecolor"),
-       "markersize", get (h, "markersize"));
-endfunction
--- a/scripts/plot/__scatter__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +0,0 @@
-## Copyright (C) 2007, 2008, 2009 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} {@var{hg} =} __scatter__ (@dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-function hg = __scatter__ (varargin)
-
-  h = varargin{1};
-  nd = varargin{2};
-  fcn = varargin{3};
-  x = varargin{4}(:);
-  y = varargin{5}(:);
-  istart = 6;
-
-  if (nd == 3)
-    z = varargin{6}(:);
-    idx = isnan(x) | isnan (y) | isnan (z);
-    x (idx) = [];
-    y (idx) = [];
-    z (idx) = [];
-    istart = 7;
-  else
-    idx = isnan(x) | isnan (y);
-    x (idx) = [];
-    y (idx) = [];
-    z = zeros (length (x), 0);
-  endif
-
-  firstnonnumeric = Inf;
-  for i = istart:nargin
-    if (! isnumeric (varargin{i}))
-      firstnonnumeric = i;
-      break;
-    endif
-  endfor
-
-  if (istart < nargin && firstnonnumeric > istart)
-    s = varargin{istart};
-    if (isempty (s))
-      s = 6;
-    endif
-  else
-    s = 6;
-  endif
-  if (numel (s) == 1)
-    ss = s;
-    s = repmat (s, numel(x), 1);
-  endif
-
-  if (istart < nargin && firstnonnumeric > istart + 1)
-    c = varargin{istart + 1};
-    if (isvector (c))
-      if (columns (c) == 3)
-	cc = c;
-	c = repmat (c, numel(x), 1);
-      else
-	c = c(:);
-      endif
-    elseif (isempty (c))
-      cc = __next_line_color__();
-      c = repmat (cc, numel(x), 1);
-    endif
-  elseif (firstnonnumeric == istart + 1 && ischar (varargin{istart + 1}))
-    c = varargin{istart + 1};
-    firstnonnumeric++;
-  else
-    cc = __next_line_color__();
-    c = repmat (cc, numel(x), 1);
-  endif
-
-  newargs = {};
-  filled = false;
-  have_marker = false;
-  marker = "o";
-  iarg = firstnonnumeric;
-  while (iarg <= nargin)
-    arg = varargin{iarg++};
-    if (ischar (arg) && strncmpi (arg, "filled", 6))
-      filled = true;
-    elseif ((ischar (arg) || iscell (arg)) && ! have_marker)
-      [linespec, valid] = __pltopt__ (fcn, arg, false);
-      if (valid)
-	have_marker = true;
-	marker = linespec.marker;
-	if (strncmp (marker, "none", 4))
-	  marker = "o";
-	endif
-      else
-	error ("%s: invalid linespec", fcn);
-      endif
-    else
-      newargs{end+1} = arg;
-      if (iarg <= nargin)
-	newargs{end+1} = varagin{iarg++};
-      endif
-    endif
-  endwhile
-
-  hg = hggroup ();
-  newargs = __add_datasource__ (fcn, hg, {"x", "y", "z", "c", "size"}, 
-			     newargs{:});
-
-  addproperty ("xdata", hg, "data", x);
-  addproperty ("ydata", hg, "data", y);
-  addproperty ("zdata", hg, "data", z);
-  if (exist ("cc", "var"))
-    addproperty ("cdata", hg, "data", cc);
-  else
-    addproperty ("cdata", hg, "data", c);
-  endif
-  if (exist ("ss", "var"))
-    addproperty ("sizedata", hg, "data", ss);
-  else
-    addproperty ("sizedata", hg, "data", s);
-  endif
-  addlistener (hg, "xdata", @update_data);
-  addlistener (hg, "ydata", @update_data);
-  addlistener (hg, "zdata", @update_data);
-  addlistener (hg, "cdata", @update_data);
-  addlistener (hg, "sizedata", @update_data);
-
-  if (ischar (c))
-    for i = 1 : numel (x)
-      h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:),
-			"faces", 1, "vertices", [x(i), y(i), z(i,:)], 
-			"facecolor", "none", "edgecolor", c, "marker", marker, 
-			"markersize", s(i), "linestyle", "none");
-      if (filled)
-	set(h, "markerfacecolor", c); 
-      endif
-    endfor
-  else
-    for i = 1 : numel (x)
-      h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:),
-			"faces", 1, "vertices", [x(i), y(i), z(i,:)], 
-			"facecolor", "none", "edgecolor", "flat", 
-			"cdata", reshape(c(i,:),[1,size(c)(2:end)]), 
-			"marker", marker, "markersize", s(i), 
-			"linestyle", "none");
-      if (filled)
-	set(h, "markerfacecolor", "flat"); 
-      endif
-    endfor
-    ax = get (hg, "parent");
-    clim = get (ax, "clim");
-    if (min(c(:)) < clim(1))
-      clim(1) = min(c(:));
-      set (ax, "clim", clim);
-    endif
-    if (max(c(:)) > clim(2))
-      set (ax, "clim", [clim(1), max(c(:))]);
-    endif
-  endif
-
-  addproperty ("linewidth", hg, "patchlinewidth", 0.5);
-  addproperty ("marker", hg, "patchmarker", marker);
-  if (numel (x) > 0)
-    addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", "none");
-    addproperty ("markeredgecolor", hg, "patchmarkeredgecolor", "none");
-  else
-    addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", 
-		 get (h, "markerfacecolor"));
-    addproperty ("markeredgecolor", hg, "patchmarkeredgecolor",
-		 get (h, "edgecolor"));
-  endif
-  addlistener (hg, "linewidth", @update_props); 
-  addlistener (hg, "marker", @update_props); 
-  addlistener (hg, "markerfacecolor", @update_props); 
-  addlistener (hg, "markeredgecolor", @update_props);
-
-  if (! isempty (newargs))
-    set (hg, newargs{:})
-  endif
-
-endfunction
-
-function update_props (h, d)
-  lw = get (h, "linewidth");
-  m = get (h, "marker");
-  fc = get (h, "markerfacecolor");
-  ec = get (h, "markeredgecolor");
-  kids = get (h, "children");
-
-  for i = 1 : numel (kids)
-    set (kids (i), "linewidth", lw, "marker", m, "markerfacecolor", fc, 
-	 "edgecolor", ec)
-  endfor
-endfunction
-
-function update_data (h, d)
-  x1 = get (h, "xdata");
-  y1 = get (h, "ydata");
-  z1 = get (h, "zdata");
-  c1 = get (h, "cdata");
-  if (!ischar (c1) && rows (c1) == 1)
-    c1 = repmat (c1, numel (x1), 1);
-  endif
-  size1 = get (h, "sizedata");
-  if (numel (size1) == 1)
-    size1 = repmat (size1, numel (x1), 1);
-  endif
-  hlist = get (h, "children");
-  if (ischar (c1))
-    if (isempty (z1))
-      for i = 1 : length (hlist)
-	set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", c1,
-	     "markersize", size1(i));
-      endfor
-    else
-      for i = 1 : length (hlist)
-	set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", c1,
-	     "markersize", size1(i));
-      endfor
-    endif
-  else
-    if (isempty (z1))
-      for i = 1 : length (hlist)
-	set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", 
-	     reshape(c1(i,:),[1, size(c1)(2:end)]), "markersize", size1(i));
-      endfor
-    else
-      for i = 1 : length (hlist)
-	set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", 
-	     reshape(c1(i,:),[1, size(c1)(2:end)]), "markersize", size1(i));
-      endfor
-    endif
-  endif
-endfunction
--- a/scripts/plot/__stem__.m	Tue Dec 01 10:38:27 2009 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,553 +0,0 @@
-## Copyright (C) 2006, 2007, 2008, 2009 Michel D. Schmid
-##
-## 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} {@var{h} =} __stem__ (@var{have_z}, @var{varargin})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: Michel D. Schmid <michaelschmid@users.sourceforge.net>
-## Adapted-by: jwe
-
-function h = __stem__ (have_z, varargin)
-
-  if (have_z)
-    caller = "stem3";
-  else
-    caller = "stem";
-  endif
-
-  [ax, varargin, nargin] = __plt_get_axis_arg__ (caller, varargin{:});
-
-  [x, y, z, dofill, llc, ls, mmc, ms, varargin] = ...
-      check_stem_arg (have_z, varargin{:});
-
-  oldax = gca ();
-  unwind_protect
-    axes (ax);
-    hold_state = get (ax, "nextplot");
-    newplot ();
-    h = [];
-
-    nx = rows (x);
-    for i = 1: columns (x)
-      if (have_z)
-	xt = x(:)';
-	xt = [xt; xt; NaN(1, nx)](:);
-	yt = y(:)';
-	yt = [yt; yt; NaN(1, nx)](:);
-	zt = z(:)';
-	zt = [zeros(1, nx); zt; NaN(1, nx)](:);
-      else
-	xt = x(:, i)';
-	xt = [xt; xt; NaN(1, nx)](:);
-	yt = y(:, i)';
-	yt = [zeros(1, nx); yt; NaN(1, nx)](:);
-      endif
-
-      hg  = hggroup ();
-      h = [h; hg];
-      args = __add_datasource__ (caller, hg, {"x", "y", "z"}, varargin{:});
-      
-      if (i == 1)
-	set (ax, "nextplot", "add");
-      endif
-
-      if (isempty (llc))
-	lc = __next_line_color__ ();
-      else
-	lc = llc;
-      endif
-
-      if (isempty (mmc))
-	mc = lc;
-      else
-	mc = mmc;
-      endif
-
-      if (dofill)
-	fc = mc;
-      else
-	fc = "none";
-      endif
-
-      if (have_z)
-	h_stems = plot3 (xt, yt, zt, "color", lc, "linestyle", ls, 
-			 "parent", hg, x, y, z, "color", mc,
-			 "marker",  ms, "linestyle", "none",
-			 "markerfacecolor", fc, "parent", hg);
-
-	h_baseline = [];
-      else
-	h_stems = plot (xt, yt, "color", lc, "linestyle", ls,
-			"parent", hg, x(:,i), y(:, i), "color", mc, "marker",
-			ms, "linestyle", "none", "markerfacecolor",
-			fc, "parent", hg); 
-
-	if (i == 1)
-	  x_axis_range = get (ax, "xlim");
-	  h_baseline = line (x_axis_range, [0, 0], "color", [0, 0, 0]);
-	  set (h_baseline, "handlevisibility", "off");
-	  set (h_baseline, "xliminclude", "off");
-	  addlistener (ax, "xlim", @update_xlim);
-	  addlistener (h_baseline, "ydata", @update_baseline);
-	  addlistener (h_baseline, "visible", @update_baseline);
-	endif
-      endif
-
-      ## Setup the hggroup and listeners.
-      addproperty ("showbaseline", hg, "radio", "{on}|off");
-      addproperty ("basevalue", hg, "data", 0);
-      addproperty ("baseline", hg, "data", h_baseline);
-
-      if (!have_z)
-	addlistener (hg, "showbaseline", @show_baseline);
-	addlistener (hg, "basevalue", @move_baseline); 
-      endif
-
-      addproperty ("color", hg, "linecolor", lc);
-      addproperty ("linewidth", hg, "linelinewidth", 0.5);
-      addproperty ("linestyle", hg, "linelinestyle", ls);
-      addproperty ("marker", hg, "linemarker", ms);
-      addproperty ("markerfacecolor", hg, "linemarkerfacecolor", fc);
-      addproperty ("markersize", hg, "linemarkersize", 6);
-
-      addlistener (hg, "color", @update_props);
-      addlistener (hg, "linewidth", @update_props); 
-      addlistener (hg, "linestyle", @update_props); 
-      addlistener (hg, "marker", @update_props); 
-      addlistener (hg, "markerfacecolor", @update_props); 
-      addlistener (hg, "markersize", @update_props);
-
-      addproperty ("xdata", hg, "data", x(:, i));
-      addproperty ("ydata", hg, "data", y(:, i));
-      if (have_z)
-	addproperty ("zdata", hg, "data", z(:, i));
-      else
-	addproperty ("zdata", hg, "data", []);
-      endif
-
-      addlistener (hg, "xdata", @update_data);
-      addlistener (hg, "ydata", @update_data);
-      addlistener (hg, "zdata", @update_data);
-
-      if (! isempty (args))
-	set (hg, args{:});
-      endif
-      if (i == 1 && !isempty(h_baseline))
-	set (h_baseline, "parent", get (hg, "parent"));
-      endif
-    endfor
-
-  unwind_protect_cleanup
-    set (ax, "nextplot", hold_state);
-    axes (oldax);
-  end_unwind_protect
-endfunction
-
-function [x, y, z, dofill, lc, ls, mc, ms, newargs] = check_stem_arg (have_z, varargin)
-
-  ## FIXME -- there seems to be a lot of duplicated code in this
-  ## function.  It seems like it should be possible to simplify things
-  ## by combining some of the nearly identical code sections into
-  ## additional subfunctions.
-
-  if (have_z)
-    caller = "stem3";
-  else
-    caller = "stem";
-  endif
-
-  ## Remove prop/val pairs from data to consider.
-  i = 2;
-  newargs = {};
-  while (i < length (varargin))
-    if (ischar (varargin{i}) && !(strcmpi ("fill", varargin{i})
-				  || strcmpi ("filled", varargin{i})))
-      newargs{end + 1} = varargin{i};
-      newargs{end + 1} = varargin{i + 1};
-      nargin = nargin - 2;
-      varargin(i:i+1) = [];
-    else
-      i++;
-    endif
-  endwhile
-
-  ## set specifiers to default values.
-  [lc, ls, mc, ms] = set_default_values ();
-  dofill = 0;
-  fill_2 = 0;
-  linespec_2 = 0;
-  z = [];
-
-  ## Check input arguments.
-  if (nargin == 2)
-    if (have_z)
-      z = varargin{1};
-      x = 1:rows (z);
-      y = 1:columns (z);
-    else
-      y = varargin{1};
-      if (isvector (y))
-	x = 1:length (y);
-      elseif (ismatrix (y))
-	x = 1:rows (y);
-      else 
-	error ("stem: Y must be a matrix");
-      endif # in each case, x & y will be defined
-    endif
-  elseif (nargin == 3)
-    ## Several possibilities
-    ##
-    ## 1. the real y data
-    ## 2. 'filled'
-    ## 3. line spec
-    if (ischar (varargin{2}))
-      ## Only 2. or 3. possible.
-      if (strcmpi ("fill", varargin{2}) || strcmpi ("filled", varargin{2}))
-	dofill = 1;
-      else
-	## Parse the linespec.
-	[lc, ls, mc, ms] = stem_line_spec (caller, varargin{2});
-      endif
-      if (have_z)
-	z = varargin{1};
-	x = 1:rows (z);
-	y = 1:columns (z);
-      else
-	y = varargin{1};
-	if (isvector (y))
-	  x = 1:length (y);
-	elseif (ismatrix (y))
-	  x = 1:rows (y);
-	else
-	  error ("stem: Y must be a matrix");
-	endif # in each case, x & y will be defined
-      endif
-    else
-      if (have_z)
-	error ("stem3: must define X, Y and Z");
-      else
-	## Must be the real y data.
-	x = varargin{1};
-	y = varargin{2};
-	if (! (ismatrix (x) && ismatrix (y)))
-	  error ("stem: X and Y must be matrices");
-	endif
-      endif
-    endif
-  elseif (nargin == 4)
-    ## Again, several possibilities:
-    ##
-    ## arg2 1. real y
-    ## arg2 2. 'filled' or linespec
-    ## arg3 1. real z
-    ## arg3 2. 'filled' or linespec
-    if (ischar (varargin{2}))
-      ## Only arg2 2. / arg3 1. & arg3 3. are possible.
-      if (strcmpi ("fill", varargin{2}) || strcmpi ("filled", varargin{2}))
-	dofill = 1;
-	fill_2 = 1; # Be sure, no second "fill" is in the arguments.
-      else
-	## Must be a linespec.
-	[lc, ls, mc, ms] = stem_line_spec (caller, varargin{2});
-	linespec_2 = 1;
-      endif
-      if (have_z)
-	z = varargin{1};
-	x = 1:rows (z);
-	y = 1:columns (z);
-      else
-	y = varargin{1};
-	if (isvector (y))
-	  x = 1:length (y);
-	elseif (ismatrix (y))
-	  x = 1:rows (y);
-	else
-	  error ("stem: Y must be a matrix");
-	endif # in each case, x & y will be defined
-      endif
-    else
-      if (have_z)
-	x = varargin{1};
-	y = varargin{2};
-	z = varargin{3};
-	if (! (ismatrix (x) && ismatrix (y) && ismatrix (z)))
-	  error ("stem3: X, Y and Z must be matrices");
-	endif
-      else
-	## must be the real y data.
-	x = varargin{1};
-	y = varargin{2};
-	if (! (ismatrix (x) && ismatrix (y)))
-	  error ("stem: X and Y must be matrices");
-	endif
-      endif
-    endif # if ischar(varargin{2})
-    if (! have_z)
-      ## varargin{3} must be char.
-      ## Check for "fill.
-      if ((strcmpi (varargin{3}, "fill") || strcmpi (varargin{3}, "filled"))
-	  && fill_2)
-	error ("stem: duplicate fill argument");
-      elseif (strcmpi ("fill", varargin{3}) && linespec_2)
-	## Must be "fill".
-	dofill = 1;
-	fill_2 = 1;
-      elseif ((strcmpi (varargin{3}, "fill") || strcmpi (varargin{3}, "filled"))
-	  && !linespec_2)
-	## Must be "fill".
-	dofill = 1;
-	fill_2 = 1;
-      elseif (! linespec_2)
-	## Must be linespec.
-	[lc, ls, mc, ms] = stem_line_spec (caller, varargin{3});
-	linespec_2 = 1;
-      endif
-    endif
-  elseif (nargin == 5)
-    if (have_z)
-      x = varargin{1};
-      y = varargin{2};
-      z = varargin{3};
-      if (! (ismatrix (x) && ismatrix (y) && ismatrix (z)))
-	error ("stem3: X, Y and Z must be matrices");
-      endif
-    else
-      x = varargin{1};
-      y = varargin{2};
-      if (! (ismatrix (x) && ismatrix (y)))
-	error ("stem: X and Y must be matrices");
-      endif
-    endif
-
-    if (! have_z)
-      if (strcmpi (varargin{3}, "fill") || strcmpi (varargin{3}, "filled"))
-	dofill = 1;
-	fill_2 = 1; # Be sure, no second "fill" is in the arguments.
-      else
-	## Must be a linespec.
-	[lc, ls, mc, ms] = stem_line_spec (caller, varargin{3});
-	linespec_2 = 1;
-      endif
-    endif
-
-    ## Check for "fill".
-    if ((strcmpi (varargin{4}, "fill") || strcmpi (varargin{4}, "filled"))
-	&& fill_2)
-      error ("%s: duplicate fill argument", caller);
-    elseif ((strcmpi (varargin{4}, "fill") || strcmpi (varargin{4}, "filled"))
-	&& linespec_2)
-      ## Must be "fill".
-      dofill = 1;
-      fill_2 = 1;
-    elseif (!strcmpi (varargin{4}, "fill") && !strcmpi (varargin{4}, "filled")
-	&& !linespec_2)
-      ## Must be linespec.
-      [lc, ls, mc, ms] = stem_line_spec (caller, varargin{4});
-      linespec_2 = 1;
-    endif
-  elseif (nargin == 6 && have_z)
-    x = varargin{1};
-    y = varargin{2};
-    z = varargin{3};
-    if (! (ismatrix (x) && ismatrix (y) && ismatrix (z)))
-      error ("stem3: X, Y and Z must be matrices");
-    endif
-
-    if (strcmpi (varargin{4}, "fill") || strcmpi (varargin{4}, "filled"))
-      dofill = 1;
-      fill_2 = 1; # be sure, no second "fill" is in the arguments
-    else
-      ## Must be a linespec.
-      [lc, ls, mc, ms] = stem_line_spec (caller, varargin{4});
-      linespec_2 = 1;
-    endif
-
-    ## check for "fill" ..
-    if ((strcmpi (varargin{5}, "fill") || strcmpi (varargin{5}, "filled"))
-	&& fill_2)
-      error ("stem3: duplicate fill argument");
-    elseif ((strcmpi (varargin{5}, "fill") || strcmpi (varargin{5}, "filled"))
-	&& linespec_2)
-      ## Must be "fill".
-      dofill = 1;
-      fill_2 = 1;
-    elseif (!strcmpi (varargin{5}, "fill") && !strcmpi (varargin{5}, "filled")
-	    && !linespec_2)
-      ## Must be linespec.
-      [lc, ls, mc, ms] = stem_line_spec (caller, varargin{5});
-      linespec_2 = 1;
-    endif
-  else
-    error ("%s: incorrect number of arguments", caller);
-  endif
-
-  ## Check sizes of x, y and z.
-  if (have_z)
-    if (!size_equal (x, y, z))
-      error ("stem3: inconsistent size of x, y and z");
-    else
-      x = x(:);
-      y = y(:);
-      z = z(:);
-    endif
-  else
-    if (isvector (x))
-      x = x(:);
-      if (isvector (y))
-	if (length (x) != length (y))
-	  error ("stem: inconsistent size of x and y");
-	else
-	  y = y(:);
-	endif
-      else
-	if (length (x) == rows (y))
-	  x = repmat (x(:), 1, columns (y));
-	else
-	  error ("stem: inconsistent size of x and y");
-	endif
-      endif
-    elseif (!size_equal (x, y))
-      error ("stem: inconsistent size of x and y");
-    endif
-  endif
-
-endfunction
-
-function [lc, ls, mc, ms] = stem_line_spec (caller, str)
-  if (! ischar (str))
-    error ("%s: expecting argument to be \"fill\" or a string of specifiers",
-	   caller);
-  endif
-  [lc, ls, mc, ms] = set_default_values ();
-  ## Parse the line specifier string.
-  cur_props = __pltopt__ ("stem", str, false);
-  for i = 1:length(cur_props)
-    if (isfield (cur_props(i), "color") && ! isempty (cur_props(i).color)); # means line color
-      mc = lc = cur_props(i).color;
-    elseif (isfield (cur_props(i), "linestyle"))
-      ls = cur_props(i).linestyle;
-    elseif (isfield (cur_props(i), "marker") && ! strcmpi (cur_props(i).marker, "none"))
-      ms = cur_props(i).marker;
-    endif
-  endfor
-endfunction
-
-function [lc, ls, mc, ms] = set_default_values ()
-  ## set default values
-  mc = [];
-  lc = [];
-  ls = "-";
-  ms = "o";
-endfunction
-
-function update_xlim (h, d)
-  kids = get (h, "children");
-  xlim = get (h, "xlim");
-
-  for i = 1 : length (kids)
-    obj = get (kids (i));
-    if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline"))
-      if (any (get (obj.baseline, "xdata") != xlim))
-	set (obj.baseline, "xdata", xlim);
-      endif
-    endif
-  endfor
-endfunction
-
-function update_baseline (h, d)
-  visible = get (h, "visible");
-  ydata = get (h, "ydata")(1);
-
-  kids = get (get (h, "parent"), "children");
-  for i = 1 : length (kids)
-    obj = get (kids (i));
-    if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") 
-	&& obj.baseline == h)
-      ## Only alter if changed to avoid recursion of the listener functions
-      if (! strcmpi (get (kids(i), "showbaseline"), visible))
-	set (kids (i), "showbaseline", visible);
-      endif
-      if (! strcmpi (get (kids(i), "basevalue"), visible))
-	set (kids (i), "basevalue", ydata);
-      endif
-    endif
-  endfor
-endfunction
-
-function show_baseline (h, d)
-  set (get (h, "baseline"), "visible", get (h, "showbaseline"));
-endfunction
-
-function move_baseline (h, d)
-  b0 = get (h, "basevalue");
-  bl = get (h, "baseline");
-
-  if (get (bl, "ydata") != [b0, b0])
-    set (bl, "ydata", [b0, b0]);
-  endif
-
-  kids = get (h, "children");
-  yt = get(h, "ydata")(:)';
-  ny = length (yt);
-  yt = [b0 * ones(1, ny); yt; NaN(1, ny)](:);
-  set (kids(2), "ydata", yt);
-endfunction
-
-function update_props (h, d)
-  kids = get (h, "children");
-  set (kids(2), "color", get (h, "color"), 
-       "linewidth", get (h, "linewidth"),
-       "linestyle", get (h, "linestyle"));
-  set (kids(1), "color", get (h, "color"), 
-       "marker", get (h, "marker"),
-       "markerfacecolor", get (h, "markerfacecolor"),
-       "markersize", get (h, "markersize"));
-endfunction
-
-function update_data (h, d)
-  x = get (h, "xdata");
-  y = get (h, "ydata");
-  z = get (h, "zdata");
-
-  if (!isempty (z) && size_equal (x, y, z))
-    error ("stem3: inconsistent size of x, y and z");
-  elseif (numel(x) != numel (y))
-    error ("stem: inconsistent size of x and y");
-  else
-    bl = get (h, "basevalue");
-    nx = numel (x);
-    x = x(:)';
-    xt = [x; x; NaN(1, nx)](:);
-    if (! isempty (z))
-      y = y(:)';
-      yt = [y; y; NaN(1, nx)](:);
-      z = z(:)';
-      zt = [bl * ones(1, nx); z; NaN(1, nx)](:);
-    else
-      y = y(:)';
-      yt = [bl * ones(1, nx); y; NaN(1, nx)](:);
-      zt = [];
-    endif
-
-    kids = get (h, "children");
-    set (kids(2), "xdata", xt, "ydata", yt, "zdata", zt)
-    set (kids(1), "xdata", x, "ydata", y, "zdata", z)
-  endif
-endfunction
--- a/scripts/plot/area.m	Tue Dec 01 10:38:27 2009 -0800
+++ b/scripts/plot/area.m	Tue Dec 01 15:59:43 2009 -0500
@@ -1,4 +1,5 @@
 ## Copyright (C) 2007, 2008, 2009 Michael Goffioul
+## Copyright (C) 2007, 2008, 2009 David Bateman
 ##
 ## This file is part of Octave.
 ##
@@ -98,3 +99,108 @@
   endif
 
 endfunction
+
+function retval = __area__ (ax, x, y, bv, varargin)
+
+  y0 = bv * ones (1, rows (y));
+  y0 = zeros (1, rows (y));
+  retval = [];
+  for i = 1: size (y, 2);
+    hg = hggroup ();
+    retval = [retval; hg];
+    args = __add_datasource__ ("area", hg, {"x", "y"}, varargin{:});
+
+    x1 = x(:, 1).';
+    y1 = y (:, i).';
+    addproperty ("xdata", hg, "data", x1);
+    addproperty ("ydata", hg, "data", y1);
+
+    addlistener (hg, "xdata", @update_data);
+    addlistener (hg, "ydata", @update_data);
+
+    if (i == 1)
+      h = patch (ax, [x1(1), x1, fliplr(x1)], [bv, y1, bv*ones(1, length(y1))],
+		 __next_line_color__ (), "parent", hg);
+    else
+      y1 = y0 + y1;
+      h = patch (ax, [x1(1), x1, fliplr(x1)], [y0(1), y1, fliplr(y0)],
+		 __next_line_color__ (), "parent", hg);
+    endif
+
+    y0 = y1;
+
+    addproperty ("basevalue", hg, "data", bv);
+    addlistener (hg, "basevalue", @move_baseline); 
+
+    addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor"));
+    addproperty ("linewidth", hg, "patchlinewidth", get (h, "linewidth"));
+    addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle"));
+    addproperty ("facecolor", hg, "patchfacecolor", get (h, "facecolor"));
+
+    addlistener (hg, "edgecolor", @update_props);
+    addlistener (hg, "linewidth", @update_props); 
+    addlistener (hg, "linestyle", @update_props); 
+    addlistener (hg, "facecolor", @update_props); 
+
+    addproperty ("areagroup", hg, "data");
+    set (retval, "areagroup", retval);
+
+    if (! isempty (args))
+      set (hg, args{:});
+    endif
+  endfor
+
+endfunction
+
+function update_props (h, d)
+  kids = get (h, "children");
+  set (kids, "edgecolor", get (h, "edgecolor"), 
+       "linewidth", get (h, "linewidth"),
+       "linestyle", get (h, "linestyle"),
+       "facecolor", get (h, "facecolor"));
+endfunction
+
+function move_baseline (h, d)
+  persistent recursion = false;
+
+  ## Don't allow recursion
+  if (! recursion)
+    unwind_protect
+      recursion = true;
+      hlist = get (h, "areagroup");
+      b0 = get (h, "basevalue");
+
+      for hh = hlist(:)'
+	if (hh != h)
+	  b1 = get (hh, "basevalue");
+	  if (b1 != b0)
+	    set (hh, "basevalue", b0);
+	  endif
+	endif
+      endfor
+      update_data (h, d);
+    unwind_protect_cleanup
+      recursion = false;
+    end_unwind_protect
+  endif
+endfunction
+
+function update_data (h, d)
+  hlist = get (h, "areagroup");
+  bv = get (h, "basevalue");
+  for i = 1 : length (hlist)
+    hh = hlist(i);
+    x1 = get (hh, "xdata")(:);
+    y1 = get (hh, "ydata")(:);
+
+    set (get (hh, "children"), "xdata", [x1(1); x1; flipud(x1)]);
+    if (i == 1)
+      set (get (hh, "children"), "ydata", [bv; y1; bv*ones(length(y1), 1)]);
+    else
+      y1 = y0 + y1;
+      set (get (hh, "children"), "ydata", [y0(1); y1; flipud(y0)]);
+    endif      
+
+    y0 = y1;
+  endfor
+endfunction
--- a/scripts/plot/module.mk	Tue Dec 01 10:38:27 2009 -0800
+++ b/scripts/plot/module.mk	Tue Dec 01 15:59:43 2009 -0500
@@ -5,20 +5,28 @@
 
 GEN_FCN_FILES += $(plot_GEN_FCN_FILES)
 
+plot_PRIVATE_FCN_FILES = \
+  plot/private/__actual_axis_position__.m \
+  plot/private/__add_datasource__.m \
+  plot/private/__axes_limits__.m \
+  plot/private/__axis_label__.m \
+  plot/private/__bar__.m \
+  plot/private/__clabel__.m \
+  plot/private/__contour__.m \
+  plot/private/__default_plot_options__.m \
+  plot/private/__errcomm__.m \
+  plot/private/__errplot__.m \
+  plot/private/__ezplot__.m \
+  plot/private/__interp_cube__.m \
+  plot/private/__line__.m \
+  plot/private/__patch__.m \
+  plot/private/__plt__.m \
+  plot/private/__pltopt__.m \
+  plot/private/__quiver__.m \
+  plot/private/__scatter__.m \
+  plot/private/__stem__.m
+
 plot_FCN_FILES = \
-  plot/__actual_axis_position__.m \
-  plot/__add_datasource__.m \
-  plot/__area__.m \
-  plot/__axes_limits__.m \
-  plot/__axis_label__.m \
-  plot/__bar__.m \
-  plot/__bars__.m \
-  plot/__clabel__.m \
-  plot/__contour__.m \
-  plot/__default_plot_options__.m \
-  plot/__errcomm__.m \
-  plot/__errplot__.m \
-  plot/__ezplot__.m \
   plot/__gnuplot_get_var__.m \
   plot/__gnuplot_ginput__.m \
   plot/__gnuplot_has_feature__.m \
@@ -27,29 +35,9 @@
   plot/__go_close_all__.m \
   plot/__go_draw_axes__.m \
   plot/__go_draw_figure__.m \
-  plot/__interp_cube__.m \
-  plot/__line__.m \
   plot/__marching_cube__.m \
   plot/__next_line_color__.m \
-  plot/__patch__.m \
-  plot/__plr1__.m \
-  plot/__plr2__.m \
-  plot/__plt1__.m \
-  plot/__plt2__.m \
-  plot/__plt2mm__.m \
-  plot/__plt2mv__.m \
-  plot/__plt2ss__.m \
-  plot/__plt2sv__.m \
-  plot/__plt2vm__.m \
-  plot/__plt2vs__.m \
-  plot/__plt2vv__.m \
-  plot/__plt__.m \
   plot/__plt_get_axis_arg__.m \
-  plot/__pltopt1__.m \
-  plot/__pltopt__.m \
-  plot/__quiver__.m \
-  plot/__scatter__.m \
-  plot/__stem__.m \
   plot/allchild.m \
   plot/ancestor.m \
   plot/area.m \
@@ -170,7 +158,8 @@
   plot/ylabel.m \
   plot/ylim.m \
   plot/zlabel.m \
-  plot/zlim.m
+  plot/zlim.m \
+  $(plot_PRIVATE_FCN_FILES)
 
 FCN_FILES += $(plot_FCN_FILES)
 
--- a/scripts/plot/polar.m	Tue Dec 01 10:38:27 2009 -0800
+++ b/scripts/plot/polar.m	Tue Dec 01 15:59:43 2009 -0500
@@ -80,3 +80,128 @@
   end_unwind_protect
 
 endfunction
+
+function retval = __plr1__ (h, theta, fmt)
+
+  if (nargin != 3)
+    print_usage ();
+  endif
+
+  [nr, nc] = size (theta);
+  if (nr == 1)
+    theta = theta';
+    tmp = nr;
+    nr = nc;
+    nc = tmp;
+  endif
+  theta_i = imag (theta);
+  if (any (theta_i))
+    rho = theta_i;
+    theta = real (theta);
+  else
+    rho = theta;
+    theta = (1:nr)';
+  endif
+
+  retval = __plr2__ (h, theta, rho, fmt);
+
+endfunction
+
+function retval = __plr2__ (h, theta, rho, fmt)
+
+  if (nargin != 4)
+    print_usage ();
+  endif
+
+  if (any (imag (theta)))
+    theta = real (theta);
+  endif
+
+  if (any (imag (rho)))
+    rho = real (rho);
+  endif
+
+  if (isscalar (theta))
+    if (isscalar (rho))
+      x = rho * cos (theta);
+      y = rho * sin (theta);
+      retval = __plt__ ("polar", h, x, y, fmt);
+    else
+      error ("__plr2__: invalid data for plotting");
+    endif
+  elseif (isvector (theta))
+    if (isvector (rho))
+      if (length (theta) != length (rho))
+        error ("__plr2__: vector lengths must match");
+      endif
+      if (rows (rho) == 1)
+        rho = rho';
+      endif
+      if (rows (theta) == 1)
+        theta = theta';
+      endif
+      x = rho .* cos (theta);
+      y = rho .* sin (theta);
+      retval = __plt__ ("polar", h, x, y, fmt);
+    elseif (ismatrix (rho))
+      [t_nr, t_nc] = size (theta);
+      if (t_nr == 1)
+        theta = theta';
+        tmp = t_nr;
+        t_nr = t_nc;
+        t_nc = tmp;
+      endif
+      [r_nr, r_nc] = size (rho);
+      if (t_nr != r_nr)
+        rho = rho';
+        tmp = r_nr;
+        r_nr = r_nc;
+        r_nc = tmp;
+      endif
+      if (t_nr != r_nr)
+        error ("__plr2__: vector and matrix sizes must match");
+      endif
+      x = diag (cos (theta)) * rho;
+      y = diag (sin (theta)) * rho;
+      retval = __plt__ ("polar", h, x, y, fmt);
+    else
+      error ("__plr2__: invalid data for plotting");
+    endif
+  elseif (ismatrix (theta))
+    if (isvector (rho))
+      [r_nr, r_nc] = size (rho);
+      if (r_nr == 1)
+        rho = rho';
+        tmp = r_nr;
+        r_nr = r_nc;
+        r_nc = tmp;
+      endif
+      [t_nr, t_nc] = size (theta);
+      if (r_nr != t_nr)
+        theta = theta';
+        tmp = t_nr;
+        t_nr = t_nc;
+        t_nc = tmp;
+      endif
+      if (r_nr != t_nr)
+        error ("__plr2__: vector and matrix sizes must match");
+      endif
+      diag_r = diag (rho);
+      x = diag_r * cos (theta);
+      y = diag_r * sin (theta);
+      retval = __plt__ ("polar", h, x, y, fmt);
+    elseif (ismatrix (rho))
+      if (! size_equal (rho, theta))
+        error ("__plr2__: matrix dimensions must match");
+      endif
+      x = rho .* cos (theta);
+      y = rho .* sin (theta);
+      retval = __plt__ ("polar", h, x, y, fmt);
+    else
+      error ("__plr2__: invalid data for plotting");
+    endif
+  else
+    error ("__plr2__: invalid data for plotting");
+  endif
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__actual_axis_position__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,88 @@
+## Copyright (C) 2009 Ben Abbott
+##
+## 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} {} __actual_axis_position__ (@var{h})
+## @deftypefnx {Function File} {} __actual_axis_position__ (@var{axis_struct})
+## Undocumented internal function.
+## @end deftypefn
+
+## Author: Ben Abbott
+
+function pos = __actual_axis_position__ (axis_obj)
+  if (ishandle (axis_obj))
+    axis_obj = get (axis_obj);
+  endif
+
+  ## When using {rltb}margin, Gnuplot does not handle the specified
+  ## aspect ratio properly, so handle it here.
+  if (__calc_dimensions__ (axis_obj) == 3)
+    ## FIXME -- this works for "axis square", but has not been
+    ##          thoroughly tested for other aspect ratios.
+    aspect_ratio_2d = [max(axis_obj.dataaspectratio(1:2)), ...
+			   axis_obj.dataaspectratio(3)/sqrt(2)];
+  else
+    aspect_ratio_2d = axis_obj.dataaspectratio(1:2);
+  endif
+  orig_fig_units = get (axis_obj.parent, "units");
+  orig_fig_position = get (axis_obj.parent, "units");
+  unwind_protect
+    set (axis_obj.parent, "units", "pixels")
+    fig_position = get (axis_obj.parent, "position");
+    pos_in_pixels = axis_obj.position .* fig_position([3, 4, 3, 4]);
+    orig_aspect_ratio_2d = pos_in_pixels(3:4);
+    rel_aspect_ratio_2d =  aspect_ratio_2d ./ orig_aspect_ratio_2d;
+    rel_aspect_ratio_2d = rel_aspect_ratio_2d ./ max (rel_aspect_ratio_2d);
+    if (rel_aspect_ratio_2d(1) < rel_aspect_ratio_2d(2));
+      dx = (1.0 - rel_aspect_ratio_2d(1)) * pos_in_pixels(3);
+      pos_in_pixels = pos_in_pixels + dx*[0.5, 0.0, -1.0, 0.0];
+    elseif (rel_aspect_ratio_2d(1) > rel_aspect_ratio_2d(2))
+      dy = (1.0 - rel_aspect_ratio_2d(2)) * pos_in_pixels(4);
+      pos_in_pixels = pos_in_pixels + dy*[0.0, 0.5, 0.0, -1.0];
+    endif
+    pos = pos_in_pixels ./ fig_position([3, 4, 3, 4]);
+  unwind_protect_cleanup
+    set (axis_obj.parent, "units", orig_fig_units)
+    set (axis_obj.parent, "units", orig_fig_position)
+  end_unwind_protect
+
+endfunction
+
+function nd = __calc_dimensions__ (obj)
+  kids = obj.children;
+  nd = 2;
+  for i = 1:length (kids)
+    obj = get (kids(i));
+    switch (obj.type)
+      case {"image", "text"}
+        ## ignore as they 
+      case {"line", "patch"}
+        if (! isempty (obj.zdata))
+          nd = 3;
+        endif
+      case "surface"
+        nd = 3;
+      case "hggroup"
+        obj_nd = __calc_dimensions__ (obj);
+        if (obj_nd == 3)
+          nd = 3;
+        endif
+    endswitch
+  endfor
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__axes_limits__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,52 @@
+## Copyright (C) 2007, 2008, 2009 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} {} __axes_limits__ (@var{fcn}, @dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+function retval = __axes_limits__ (fcn, varargin)
+
+  retval = [];
+
+  fcnmode = sprintf ("%smode", fcn);
+
+  [h, varargin, nargin] = __plt_get_axis_arg__ (fcn, varargin{:});
+
+  if (nargin == 0)
+    retval = get (h, fcn);
+  else
+    arg = varargin{1};
+
+    if (ischar (arg))
+      if (strcmpi (arg, "mode"))
+	retval = get (h, fcnmode);
+      elseif (strcmpi (arg, "auto") ||  strcmpi (arg, "manual"))
+	set (h, fcnmode, arg);
+      endif
+    else
+      if (!isnumeric (arg) && any (size(arg(:)) != [2, 1]))
+	error ("%s: argument must be a 2 element vector", fcn);
+      else
+	set (h, fcn, arg(:));
+      endif
+    endif
+  endif
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__axis_label__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,49 @@
+## Copyright (C) 1996, 1997, 2000, 2003, 2005, 2006, 2007, 2008,
+##               2009 John W. Eaton 
+##
+## 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} {} __axis_label__ (@var{caller}, @var{txt}, @dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+## Author: jwe
+
+function retval = __axis_label__ (caller, txt, varargin)
+
+  if (ischar (txt))
+    ca = gca ();
+
+    h = get (gca (), caller);
+
+    set (h, "fontangle", get (ca, "fontangle"),
+         "fontname", get (ca, "fontname"),
+         "fontsize", get (ca, "fontsize"),
+         "fontunits", get (ca, "fontunits"),
+         "fontweight", get (ca, "fontweight"),
+         "string", txt,
+	 varargin{:});
+
+    if (nargout > 0)
+      retval = h;
+    endif
+  else
+    error ("%s: expecting first argument to be character string", caller);
+  endif
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__bar__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,423 @@
+## Copyright (C) 1996, 1997, 2007, 2008, 2009 John W. Eaton
+##
+## 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} {} __bar__ (@var{vertical}, @var{func}, @dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+## Author: jwe
+
+function varargout = __bar__ (vertical, func, varargin)
+
+  [h, varargin] = __plt_get_axis_arg__ ((nargout > 1), func, varargin{:});
+
+  ## Slightly smaller than 0.8 to avoid clipping issue in gnuplot 4.0
+  width = 0.8 - 10 * eps; 
+  group = true;
+  bv = 0;
+
+  if (nargin < 3)
+    print_usage ();
+  endif
+
+  if (nargin > 3 && isnumeric (varargin{2}))
+    x = varargin{1};
+    if (isvector (x))
+      x = x(:);
+    endif
+    y = varargin{2};
+    if (isvector (y))
+      y = y(:);
+    endif
+    if (size (x, 1) != size (y, 1))
+      y = varargin{1};
+      if (isvector (y))
+	y = y(:);
+      endif
+      x = [1:size(y,1)]';
+      idx = 2;
+    else
+      if (! isvector (x))
+	error ("%s: x must be a vector", func);
+      endif
+      idx = 3;
+    endif
+  else
+    y = varargin{1};
+    if (isvector (y))
+      y = y(:);
+    endif
+    x = [1:size(y,1)]';
+    idx = 2;
+  endif
+      
+  newargs = {};
+  have_line_spec = false;
+  while (idx <= nargin - 2)
+    if (ischar (varargin{idx}) && strcmpi (varargin{idx}, "grouped"))
+      group = true;
+      idx++;
+    elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "stacked"))
+      group = false;
+      idx++;
+    else
+      if ((ischar (varargin{idx}) || iscell (varargin{idx}))
+	  && ! have_line_spec)
+	[linespec, valid] = __pltopt__ (func, varargin{idx}, false);
+	if (valid)
+	  have_line_spec = true;
+	  newargs = [{linespec.color}, newargs];
+	  idx++;
+	  continue;
+	endif
+      endif
+      if (isscalar(varargin{idx}))
+	width = varargin{idx++};
+      elseif (idx == nargin - 2)
+	newargs = [newargs,varargin(idx++)];
+      elseif (ischar (varargin{idx})
+	      && strcmpi (varargin{idx}, "basevalue")
+	      && isscalar (varargin{idx+1}))
+        bv = varargin{idx+1};
+        idx += 2;
+      else
+	newargs = [newargs,varargin(idx:idx+1)];
+	idx += 2;
+      endif
+    endif
+  endwhile
+
+  xlen = size (x, 1);
+  ylen = size (y, 1);
+
+  if (xlen != ylen)
+    error ("%s: length of x and y must be equal", func);
+  endif
+  if (any (x(2:end) < x(1:end-1)))
+    error ("%s: x vector values must be in ascending order", func);
+  endif
+
+  ycols = size (y, 2);
+  cutoff = min (diff (double(x))) / 2;
+  if (group)
+    delta_p = delta_m = repmat (cutoff * width / ycols, size (x));
+  else
+    delta_p = delta_m = repmat (cutoff * width, size (x));
+  endif
+  x1 = (x - delta_m)(:)';
+  x2 = (x + delta_p)(:)';
+  xb = repmat ([x1; x1; x2; x2](:), 1, ycols);
+
+  if (group)
+    offset = ((delta_p + delta_m) * [-(ycols - 1) / 2 : (ycols - 1) / 2]);
+    xb(1:4:4*ylen,:) += offset;
+    xb(2:4:4*ylen,:) += offset;
+    xb(3:4:4*ylen,:) += offset;
+    xb(4:4:4*ylen,:) += offset;
+    y0 = zeros (size (y)) + bv;
+    y1 = y;
+  else
+    y1 = cumsum(y,2);
+    y0 = [zeros(ylen,1)+bv, y1(:,1:end-1)];
+  endif
+
+  yb = zeros (4*ylen, ycols);
+  yb(1:4:4*ylen,:) = y0;
+  yb(2:4:4*ylen,:) = y1;
+  yb(3:4:4*ylen,:) = y1;
+  yb(4:4:4*ylen,:) = y0;
+
+  xb = reshape (xb, [4, numel(xb) / 4 / ycols, ycols]);
+  yb = reshape (yb, [4, numel(yb) / 4 / ycols, ycols]);
+
+  if (nargout < 2)
+    oldh = gca ();
+    unwind_protect
+      axes (h);
+      newplot ();
+
+      tmp = bars (h, vertical, x, y, xb, yb, width, group,
+		  have_line_spec, bv, newargs{:});
+      if (nargout == 1)
+	varargout{1} = tmp;
+      endif
+    unwind_protect_cleanup
+      axes (oldh);
+    end_unwind_protect
+  else
+    if (vertical)
+      varargout{1} = xb;
+      varargout{2} = yb;
+    else
+      varargout{1} = yb;
+      varargout{2} = xb;
+    endif
+  endif
+
+endfunction
+
+function tmp = bars (ax, vertical, x, y, xb, yb, width, group, have_color_spec, base_value, varargin)
+
+  ycols = columns (y);
+  clim = get (ax, "clim");
+  tmp = [];
+
+  for i = 1:ycols
+    hg = hggroup ();
+    tmp = [tmp; hg];
+    args = __add_datasource__ ("bar", hg, {"x", "y"}, varargin{:});
+    
+    if (vertical)
+      if (! have_color_spec)
+	if (ycols == 1)
+	  lev = clim(1);
+	else
+	  lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
+	endif
+	h = patch(xb(:,:,i), yb(:,:,i), "FaceColor", "flat", 
+		  "cdata", lev, "parent", hg);
+      else
+	h = patch(xb(:,:,i), yb(:,:,i), "parent", hg);
+      endif
+    else
+      if (! have_color_spec)
+	if (ycols == 1)
+	  lev = clim(1)
+	else
+	  lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
+	endif
+	h = patch(yb(:,:,i), xb(:,:,i), "FaceColor", "flat", 
+		  "cdata", lev, "parent", hg);
+      else
+	h = patch(yb(:,:,i), xb(:,:,i), "parent", hg);
+      endif
+    endif
+
+    if (i == 1)
+      x_axis_range = get (ax, "xlim");
+      h_baseline = line (x_axis_range, [0, 0], "color", [0, 0, 0]);
+      set (h_baseline, "handlevisibility", "off");
+      set (h_baseline, "xliminclude", "off");
+      addlistener (ax, "xlim", @update_xlim);
+      addlistener (h_baseline, "ydata", @update_baseline);
+      addlistener (h_baseline, "visible", @update_baseline);
+    endif
+
+    ## Setup the hggroup and listeners
+    addproperty ("showbaseline", hg, "radio", "{on}|off");
+    addproperty ("basevalue", hg, "data", base_value);
+    addproperty ("baseline", hg, "data", h_baseline);
+
+    addlistener (hg, "showbaseline", @show_baseline);
+    addlistener (hg, "basevalue", @move_baseline); 
+
+    addproperty ("barwidth", hg, "data", width);
+    if (group)
+      addproperty ("barlayout", hg, "radio", "stacked|{grouped}", "grouped");
+    else
+      addproperty ("barlayout", hg, "radio", "{stacked}|grouped", "stacked");
+    endif
+    if (vertical)
+      addproperty ("horizontal", hg, "radio", "on|{off}", "off")
+    else
+      addproperty ("horizontal", hg, "radio", "{on}|off", "on")
+    endif
+
+    addlistener (hg, "barwidth", @update_group);
+    addlistener (hg, "barlayout", @update_group);
+    addlistener (hg, "horizontal", @update_group);
+
+    addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor"));
+    addproperty ("linewidth", hg, "patchlinewidth", get (h, "linewidth"));
+    addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle"));
+    addproperty ("facecolor", hg, "patchfacecolor", get (h, "facecolor"));
+
+    addlistener (hg, "edgecolor", @update_props);
+    addlistener (hg, "linewidth", @update_props); 
+    addlistener (hg, "linestyle", @update_props); 
+    addlistener (hg, "facecolor", @update_props); 
+
+    if (isvector (x))
+      addproperty ("xdata", hg, "data", x);
+    else
+      addproperty ("xdata", hg, "data", x(:, i));
+    endif
+    addproperty ("ydata", hg, "data", y(:, i));
+ 
+    addlistener (hg, "xdata", @update_data);
+    addlistener (hg, "ydata", @update_data);
+
+    addproperty ("bargroup", hg, "data");
+    set (tmp, "bargroup", tmp);
+    if (! isempty (args))
+      set (hg, args{:});
+    endif
+    if (i == 1)
+      set (h_baseline, "parent", get (hg, "parent"));
+    endif
+  endfor
+
+  update_xlim (ax, []);
+endfunction
+
+function update_xlim (h, d)
+  kids = get (h, "children");
+  xlim = get (h, "xlim");
+
+  for i = 1 : length (kids)
+    obj = get (kids (i));
+    if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline"))
+      if (any (get (obj.baseline, "xdata") != xlim))
+	set (obj.baseline, "xdata", xlim);
+      endif
+    endif
+  endfor
+endfunction
+
+function update_baseline (h, d)
+  visible = get (h, "visible");
+  ydata = get (h, "ydata")(1);
+
+  kids = get (get (h, "parent"), "children");
+  for i = 1 : length (kids)
+    obj = get (kids (i));
+    if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") 
+	&& obj.baseline == h)
+      ## Only alter if changed to avoid recursion of the listener functions
+      if (! strcmpi (get (kids(i), "showbaseline"), visible))
+	set (kids (i), "showbaseline", visible);
+      endif
+      if (! strcmpi (get (kids(i), "basevalue"), visible))
+	set (kids (i), "basevalue", ydata);
+      endif
+    endif
+  endfor
+endfunction
+
+function show_baseline (h, d)
+  persistent recursion = false;
+
+  ## Don't allow recursion
+  if (! recursion)
+    unwind_protect
+      recursion = true;
+      hlist = get (h, "bargroup");
+      showbaseline = get (h, "showbaseline");
+      for hh = hlist(:)'
+	if (hh != h)
+	  set (hh, "showbaseline", showbaseline);
+	endif
+      endfor
+      set (get (h, "baseline"), "visible", showbaseline);
+    unwind_protect_cleanup
+      recursion = false;
+    end_unwind_protect
+  endif
+endfunction
+
+function move_baseline (h, d)
+  b0 = get (h, "basevalue");
+  bl = get (h, "baseline");
+
+  if (get (bl, "ydata") != [b0, b0])
+    set (bl, "ydata", [b0, b0]);
+  endif
+
+  if (strcmpi (get (h, "barlayout"), "grouped"))
+    update_data (h, d);
+  endif
+endfunction
+
+function update_props (h, d)
+  kids = get (h, "children");
+  set (kids, "edgecolor", get (h, "edgecolor"), 
+       "linewidth", get (h, "linewidth"),
+       "linestyle", get (h, "linestyle"),
+       "facecolor", get (h, "facecolor"));
+endfunction
+
+function update_data (h, d)
+  persistent recursion = false;
+
+  ## Don't allow recursion
+  if (! recursion)
+    unwind_protect
+      recursion = true;
+      hlist = get (h, "bargroup");
+      x = get (h, "xdata");
+      if (!isvector (x))
+	x = x(:);
+      endif
+      y = [];
+      for hh = hlist(:)'
+	ytmp = get (hh, "ydata");
+	y = [y ytmp(:)];
+      endfor
+
+      [xb, yb] = bar (x, y, get (h, "barwidth"), get (h, "barlayout"),
+		      "basevalue", get (h, "basevalue"));
+      ny = columns (y);
+      vert = strcmpi (get (h, "horizontal"), "off");
+
+      for i = 1:ny
+	hp = get (hlist(i), "children");
+	if (vert)
+	  set (hp, "xdata", xb(:,:,i), "ydata", yb(:,:,i));
+	else
+	  set (hp, "xdata", yb(:,:,i), "ydata", xb(:,:,i));
+	endif
+      endfor
+    unwind_protect_cleanup
+      recursion = false;
+    end_unwind_protect
+  endif
+endfunction
+
+function update_group (h, d)
+  persistent recursion = false;
+
+  ## Don't allow recursion
+  if (! recursion)
+    unwind_protect
+      recursion = true;
+      hlist = get (h, "bargroup");
+      barwidth = get(h, "barwidth");
+      barlayout = get (h, "barlayout");
+      horizontal = get (h, "horizontal");
+
+      ## To prevent recursion, only change if modified
+      for hh = hlist(:)'
+	if (hh != h)
+	  if (get (hh, "barwidth") != barwidth)
+	    set (hh, "barwidth", barwidth);
+	  endif
+	  if (! strcmpi (get (hh, "barlayout"), barlayout))
+	    set (hh, "barlayout", barlayout);
+	  endif
+	  if (! strcmpi (get (hh, "horizontal"), horizontal))
+	    set (hh, "horizontal", horizontal);
+	  endif
+	endif
+      endfor
+      update_data (h, d);
+    unwind_protect_cleanup
+      recursion = false;
+    end_unwind_protect
+  endif
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__clabel__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,115 @@
+## Copyright (C) 2008, 2009 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} {@var{h} =} __clabel__ (@var{c}, @var{v}, @var{hparent}, @var{label_spacing}, @var{z}, @var{varargin})
+## Undocumented internal function.
+## @end deftypefn
+
+function h = __clabel__ (c, v, hparent, label_spacing, z, varargin)
+  ## FIXME
+  ## Assume that the plot size is 4 by 3 inches.
+  lims = axis ();
+  xspacing = 72 * 4 / abs(lims(1) - lims(2));
+  yspacing = 72 * 3 / abs(lims(3) - lims(4));
+
+  if (isscalar (hparent) && ishandle(hparent) && 
+	strcmp (get (hparent, "type"), "hggroup"))
+    x = get (hparent, "xdata");
+    xmin = min (x(:));
+    xmax = max (x(:));
+    y = get (hparent, "ydata");
+    ymin = min (y(:));
+    ymax = max (y(:));
+  else
+    i1 = 1;
+    while (i1 < length (c))
+      clev = c(1,i1);
+      clen = c(2,i1);
+      p = c(:, i1+1:i1+clen)      
+
+      xmin = min (c(1,:));
+      xmax = max (c(1,:));
+      ymin = min (c(2,:));
+      ymax = max (c(2,:));
+
+      i1 += clen+1;
+    endwhile
+  endif
+
+  ## Decode contourc output format and place labels.
+  i1 = 1;
+  h = [];
+  while (i1 < length (c))
+    clev = c(1,i1);
+    clen = c(2,i1);
+
+    if (!isempty (v) && ! any (find (clev == v)))
+      i1 += clen+1;
+      continue;
+    endif
+
+    p = c(:, i1+1:i1+clen) .* repmat ([xspacing; yspacing], 1, clen);
+    d = sqrt (sumsq (diff (p, 1, 2)));
+    cumd = cumsum (d);
+    td = sum(d);
+    ntag = ceil (td / label_spacing);
+
+    if (all (c(:,i1+1) == c(:,i1+clen)))
+      Spacing = td / ntag;
+      pos = Spacing / 2 + [0:ntag-1] * Spacing;
+    else
+      pos = zeros(1, ntag);
+      pos(1) = (td - label_spacing * (ntag - 1)) ./ 2;
+      pos(2:ntag) = pos(1) + [1:ntag-1] * label_spacing;
+    endif
+
+    j1 = 2;
+    tlabel = sprintf ("%g", clev);
+    for i = 1 : ntag
+      tagpos = pos(i);
+      
+      while (j1 < clen && cumd(j1) < tagpos)
+	j1++;
+      endwhile
+      tpos = sum(c(:,i1+j1-1:i1+j1), 2) ./ 2;
+
+      if (tpos(1) != xmin &&  tpos(1) != xmax && 
+	  tpos(2) != ymin &&  tpos(2) != ymax)
+	trot = 180 / pi * atan2 (diff (c(2,i1+j1-1:i1+j1)),
+				 diff (c(1,i1+j1-1:i1+j1)));
+
+	if (ischar (z))
+	  ht = text (tpos(1), tpos(2), clev, tlabel, "rotation", trot, 
+		     "parent", hparent, "horizontalalignment", "center",
+		     "userdata", clev, varargin{:});
+	elseif (!isempty (z))
+	  ht = text (tpos(1), tpos(2), z, tlabel, "rotation", trot, 
+		     "parent", hparent, "horizontalalignment", "center",
+		     "userdata", clev, varargin{:});
+	else
+	  ht = text (tpos(1), tpos(2), tlabel, "rotation", trot,
+		     "parent", hparent, "horizontalalignment", "center",
+		     "userdata", clev, varargin{:});
+	endif
+	h = [h; ht];
+      endif
+    endfor
+    i1 += clen+1;
+  endwhile
+endfunction 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__contour__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,514 @@
+## Copyright (C) 2007, 2008, 2009 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} {[@var{c}, @var{hg}] =} __contour__ (@dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+function [c, hg] = __contour__ (varargin)
+  ax = varargin{1};
+  zlevel = varargin{2};
+  filled = "off";
+
+  linespec.linestyle = "-";
+  linespec.color = "auto";
+  edgecolor = "flat";
+  for i = 3 : nargin
+    arg = varargin {i};
+    if ((ischar (arg) || iscell (arg)))
+      [linespec, valid] = __pltopt__ ("__contour__", arg, false);
+      if (isempty (linespec.color))
+	linespec.color = "auto";
+      endif
+      if (valid)
+	have_line_spec = true;
+	varargin(i) = [];
+	break;
+      endif
+    endif
+  endfor
+
+  opts = {};
+  i = 3;
+  while (i < length (varargin))
+    if (ischar (varargin {i}))
+      if (strcmpi (varargin{i}, "fill"))
+	filled = varargin {i + 1};
+	varargin(i:i+1) = [];
+      elseif (strcmpi (varargin{i}, "linecolor"))
+	linespec.color = varargin {i + 1};
+	edgecolor = linespec.color;
+	if (ischar (edgecolor) && strcmpi (edgecolor, "auto"))
+	  edgecolor = "flat";
+	endif
+	varargin(i:i+1) = [];
+      elseif (strcmpi (varargin{i}, "edgecolor"))
+	linespec.color = varargin {i + 1};
+	edgecolor = linespec.color;
+	if (ischar (edgecolor) && strcmpi (edgecolor, "flat"))
+	  linespec.color = "auto";
+	endif
+	varargin(i:i+1) = [];
+      else
+	opts{end+1} = varargin{i};
+        varargin(i) = [];
+        opts{end+1} = varargin{i};
+        varargin(i) = [];
+      endif
+    else
+      i++;
+    endif
+  endwhile
+
+  if (length(varargin) < 5)
+    z1 = varargin{3};
+    x1 = 1 : rows(z1);
+    y1 = 1 : columns(z1);
+  else
+    x1 = varargin{3};
+    y1 = varargin{4};
+    z1 = varargin{5};
+  endif
+  if (length (varargin) == 4 || length (varargin) == 6)
+    vn = varargin {end};
+    vnauto = false;
+  else
+    vnauto = true;
+    vn = 10; 
+  endif
+
+  if (isscalar (vn))
+    lvl = linspace (min (z1(!isinf(z1))), max (z1(!isinf(z1))), 
+		    vn + 2)(1:end-1);
+  else
+    lvl = vn;
+  endif
+
+  if (strcmpi (filled, "on"))
+    if (isvector (x1) || isvector (y1))
+      [x1, y1] = meshgrid (x1, y1);
+    endif
+    [nr, nc] = size (z1);
+    x0 = prepad(x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2);
+    x0 = postpad(x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2);
+    x0 = [x0(1, :); x0; x0(1, :)];
+    y0 = prepad(y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1);
+    y0 = postpad(y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1));
+    y0 = [y0(:, 1), y0, y0(:, 1)];
+    z0 = -Inf(nr+2, nc+2);
+    z0(2:nr+1, 2:nc+1) = z1;
+    [c, lev] = contourc (x0, y0, z0, lvl);
+  else
+    [c, lev] = contourc (x1, y1, z1, lvl);
+  endif
+
+  hg = hggroup ();
+  opts = __add_datasource__ ("__countour__", hg, {"x", "y", "z"}, opts{:});
+
+  addproperty ("xdata", hg, "data", x1);
+  addproperty ("ydata", hg, "data", y1);
+  addproperty ("zdata", hg, "data", z1);
+  addproperty ("contourmatrix", hg, "data", c);
+
+  addlistener (hg, "xdata", @update_data);
+  addlistener (hg, "ydata", @update_data);
+  addlistener (hg, "zdata", @update_data);
+  addlistener (hg, "contourmatrix", @update_data);
+
+  addproperty ("fill", hg, "radio", "on|{off}", filled);
+
+  ## The properties zlevel and zlevelmode don't exist in matlab, but
+  ## allow the use of contourgroups with the contour3, meshc and surfc 
+  ## functions. 
+  if (isnumeric (zlevel))
+    addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", "manual")
+    addproperty ("zlevel", hg, "data", zlevel);
+  else
+    addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", zlevel)
+    if (ischar (zlevel) && strcmpi (zlevel, "manual"))
+      z = varargin{3};
+      z = 2 * (min (z(:)) - max (z(:)));
+      addproperty ("zlevel", hg, "data", z);
+    else
+      addproperty ("zlevel", hg, "data", 0.);
+    endif
+  endif
+
+  lvlstep = sum (abs (diff (lvl))) / (length (lvl) - 1);
+
+  addproperty ("levellist", hg, "data", lev);
+  addproperty ("levelstep", hg, "double", lvlstep);
+  if (vnauto)
+    addproperty ("levellistmode", hg, "radio", "{auto}|manual", "auto");
+    addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "auto");
+  elseif (isscalar (vn))
+    addproperty ("levellistmode", hg, "radio", "{auto}|manual", "auto");
+    addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "manual");
+  else
+    addproperty ("levellistmode", hg, "radio", "{auto}|manual", "manual");
+    addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "auto");
+  endif
+
+  addproperty ("labelspacing", hg, "double", 144);
+  addproperty ("textlist", hg, "data", lev);
+  addproperty ("textlistmode", hg, "radio", "{auto}|manual", "auto");
+  addproperty ("textstep", hg, "double", lvlstep);
+  addproperty ("textstepmode", hg, "radio", "{auto}|manual", "auto");
+  addproperty ("showtext", hg, "radio", "on|{off}", "off");
+
+  addproperty ("linecolor", hg, "color", linespec.color, "{auto}|none");
+  addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle);
+  addproperty ("linewidth", hg, "linelinewidth", 0.5);
+
+  ## FIXME It would be good to hide this property which is just an undocumented
+  ## alias for linecolor
+  addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none");
+
+  addlistener (hg, "fill", @update_data);
+
+  addlistener (hg, "zlevelmode", @update_zlevel);
+  addlistener (hg, "zlevel", @update_zlevel);
+
+  addlistener (hg, "levellist", @update_data);
+  addlistener (hg, "levelstep", @update_data);
+  addlistener (hg, "levellistmode", @update_data);
+  addlistener (hg, "levelstepmode", @update_data);
+
+  addlistener (hg, "labelspacing", @update_text);
+  addlistener (hg, "textlist", @update_text);
+  addlistener (hg, "textlistmode", @update_text);
+  addlistener (hg, "textstep", @update_text);
+  addlistener (hg, "textstepmode", @update_text);
+  addlistener (hg, "showtext", @update_text);
+
+  addlistener (hg, "linecolor", @update_line);
+  addlistener (hg, "linestyle", @update_line);
+  addlistener (hg, "linewidth", @update_line);
+
+  addlistener (hg, "edgecolor", @update_edgecolor);
+
+  add_patch_children (hg);
+
+  if (!isempty (opts))
+    set (hg, opts{:});
+  endif
+endfunction
+
+function add_patch_children (hg)
+  c = get (hg, "contourmatrix");
+  lev = get (hg, "levellist");
+  fill = get (hg, "fill");
+  z = get (hg, "zlevel");
+  zmode = get (hg, "zlevelmode");
+  lc = get (hg, "linecolor");
+  lw = get (hg, "linewidth");
+  ls = get (hg, "linestyle");
+  filled = get (hg, "fill");
+
+  if (strcmpi (lc, "auto"))
+    lc = "flat";
+  endif
+
+  if (strcmpi (filled, "on"))
+    if (diff (lev) < 10*eps) 
+      lvl_eps = 1e-6;
+    else
+      lvl_eps = min (diff (lev)) / 1000.0;
+    endif
+
+    ## Decode contourc output format.
+    i1 = 1;
+    ncont = 0;
+    while (i1 < columns (c))
+      ncont++;
+      cont_lev(ncont) = c(1, i1);
+      cont_len(ncont) = c(2, i1);
+      cont_idx(ncont) = i1+1;
+
+      ii = i1+1:i1+cont_len(ncont);
+      cur_cont = c(:, ii);
+      startidx = ii(1);
+      stopidx = ii(end);
+      cont_area(ncont) = polyarea (c(1, ii), c(2, ii));
+      i1 += c(2, i1) + 1;
+    endwhile
+
+    ## Handle for each level the case where we have (a) hole(s) in a patch.
+    ## Those are to be filled with the color of level below or with the
+    ## background colour.
+    for k = 1:numel (lev)
+      lvl_idx = find (abs (cont_lev - lev(k)) < lvl_eps);
+      len = numel (lvl_idx);
+      if (len > 1)
+	## mark = logical(zeros(size(lvl_idx)));
+	mark = false (size (lvl_idx));
+	a = 1;
+	while (a < len)
+	  ## take 1st patch
+          b = a + 1;
+          pa_idx = lvl_idx(a);
+          ## get pointer to contour start, and contour length
+          curr_ct_idx = cont_idx(pa_idx);
+          curr_ct_len = cont_len(pa_idx);
+	  ## get contour
+          curr_ct = c(:, curr_ct_idx:curr_ct_idx+curr_ct_len-1);
+          b_vec = (a+1):len;
+          next_ct_pt_vec = c(:, cont_idx(lvl_idx(b_vec)));
+          in = inpolygon (next_ct_pt_vec(1,:), next_ct_pt_vec(2,:),
+			  curr_ct(1, :), curr_ct(2, :));
+          mark(b_vec(in)) = !mark(b_vec(in));
+          a++;
+	endwhile
+	if (numel (mark) > 0)
+	  ## All marked contours describe a hole in a larger contour of
+	  ## the same level and must be filled with colour of level below.
+          ma_idx = lvl_idx(mark);
+          if (k > 1)
+	    ## Find color of level below.
+            tmp = find(abs(cont_lev - lev(k - 1)) < lvl_eps);
+            lvl_bel_idx = tmp(1);
+	    ## Set color of patches found.
+	    cont_lev(ma_idx) = cont_lev(lvl_bel_idx);
+          else
+	    ## Set lowest level contour to NaN.
+	    cont_lev(ma_idx) = NaN;
+          endif
+	endif
+      endif
+    endfor
+
+    ## The algorithm can create patches with the size of the plotting
+    ## area, we would like to draw only the patch with the highest level.
+    del_idx = [];
+    max_idx = find (cont_area == max (cont_area));
+    if (numel (max_idx) > 1)
+      ## delete double entries
+      del_idx = max_idx(1:end-1);
+      cont_area(del_idx) = cont_lev(del_idx) = [];
+      cont_len(del_idx) = cont_idx(del_idx) = [];
+    endif
+
+    ## Now we have everything together and can start plotting the patches
+    ## beginning with largest area.
+    [tmp, svec] = sort (cont_area);
+    len = ncont - numel (del_idx);
+    h = [];
+    for n = len:(-1):1
+      idx = svec(n);
+      ctmp = c(:, cont_idx(idx):cont_idx(idx) + cont_len(idx) - 1);
+      if (all (ctmp(:,1) == ctmp(:,end)))
+        ctmp(:, end) = [];
+      else
+	## Special case unclosed contours
+      endif
+      h = [h; patch(ctmp(1, :), ctmp(2, :), cont_lev(idx), "edgecolor", lc, 
+		    "linestyle", ls, "linewidth", lw, "parent", hg)];
+    endfor
+
+    if (min (lev) == max (lev))
+      set (gca (), "clim", [min(lev)-1, max(lev)+1]);
+    else
+      set (gca(), "clim", [min(lev), max(lev)]);
+    endif
+
+    set (gca (), "layer", "top");
+  else
+    ## Decode contourc output format.
+    i1 = 1;
+    h = [];
+    while (i1 < length (c))
+      clev = c(1,i1);
+      clen = c(2,i1);
+
+      if (all (c(:,i1+1) == c(:,i1+clen)))
+	p = c(:, i1+1:i1+clen-1);
+      else
+	p = [c(:, i1+1:i1+clen), NaN(2, 1)];
+      endif
+
+      switch (zmode)
+	case "none"
+	  h = [h; patch(p(1,:), p(2,:), "facecolor", "none", 
+			"edgecolor", lc, "linestyle", ls, "linewidth", lw,
+			"cdata", clev, "parent", hg)]; 
+	case "auto"
+	  h = [h; patch(p(1,:), p(2,:), clev * ones (1, columns (p)),
+			"facecolor", "none", "edgecolor", lc, 
+			"linestyle", ls, "linewidth", lw, "cdata", clev, 
+			"parent", hg)];
+	otherwise
+	  h = [h; patch(p(1,:), p(2,:), z * ones (1, columns (p)),
+			"facecolor", "none", "edgecolor", lc,
+			"linestyle", ls, "linewidth", lw, "cdata", clev,
+			"parent", hg)];
+      endswitch
+      i1 += clen+1;
+    endwhile
+  endif
+
+endfunction
+
+function update_zlevel (h, d)
+  z = get (h, "zlevel");
+  zmode = get (h, "zlevelmode");
+  kids = get (h, "children");
+
+  switch (zmode)
+    case "none"
+      set (kids, "zdata", []);
+    case "auto"
+      for i = 1 : length (kids)
+	set (kids(i), "zdata", get (kids (i), "cdata") .* 
+	     ones (size (get (kids (i), "xdata"))));
+      endfor
+    otherwise
+      for i = 1 : length (kids)
+	set (kids(i), "zdata", z .* ones (size (get (kids (i), "xdata"))));
+      endfor
+  endswitch
+endfunction
+
+function update_edgecolor (h, d)
+  ec = get (h, "edgecolor");
+  lc = get (h, "linecolor");
+  if (ischar (ec) && strcmpi (ec, "flat"))
+    if (! strcmpi (lc, "auto"))
+      set (h, "linecolor", "auto");
+    endif
+  elseif (! isequal (ec, lc))
+    set (h, "linecolor", ec);
+  endif
+endfunction
+
+function update_line (h, d)
+  lc = get (h, "linecolor");
+  ec = get (h, "edgecolor");
+  if (strcmpi (lc, "auto"))
+    lc = "flat";
+  endif
+  if (! isequal (ec, lc))
+    set (h, "edgecolor", lc);
+  endif
+  set (findobj (h, "type", "patch"), "edgecolor", lc,
+       "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"));
+endfunction
+
+function update_data (h, d)
+  persistent recursive = false;
+
+  if (!recursive)
+    recursive = true;
+
+    delete (get (h, "children"));
+
+    if (strcmpi (get (h, "levellistmode"), "manual"))
+      lvl = get (h, "levellist");
+    elseif (strcmpi (get (h, "levelstepmode"), "manual"))
+      z = get (h, "zdata");
+      lvl = ceil ((max(z(:)) - min (z(:)) ./ get (h, "levelstep")));
+    else
+      lvl = 10;
+    endif
+
+    if (strcmpi (get (h, "fill"), "on"))
+      X = get (h, "xdata");
+      Y = get (h, "ydata");
+      Z = get (h, "zdata");
+      if (isvector (X) || isvector (Y))
+	[X, Y] = meshgrid (X, Y);
+      endif
+      [nr, nc] = size (Z);
+      X0 = prepad(X, nc+1, 2 * X(1, 1) - X(1, 2), 2);
+      X0 = postpad(X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2);
+      X0 = [X0(1, :); X0; X0(1, :)];
+      Y0 = prepad(Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1);
+      Y0 = postpad(Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1));
+      Y0 = [Y0(:, 1), Y0, Y0(:, 1)];
+      Z0 = -Inf(nr+2, nc+2);
+      Z0(2:nr+1, 2:nc+1) = Z;
+      [c, lev] = contourc (X0, Y0, Z0, lvl);
+    else
+      [c, lev] = contourc (get (h, "xdata"), get (h, "ydata"), 
+			   get (h, "zdata"), lvl); 
+    endif
+    set (h, "contourmatrix", c);
+
+    if (strcmpi (get (h, "levellistmode"), "manual"))
+      ## Do nothing
+    elseif (strcmpi (get (h, "levelstepmode"), "manual"))
+      set (h, "levellist", lev);
+    else
+      set (h, "levellist", lev);
+      z = get (h, "zdata");
+      lvlstep = (max(z(:)) - min(z(:))) / 10;
+      set (h, "levelstep", lvlstep);
+    endif
+
+    add_patch_children (h);
+    update_text (h, d);
+  endif
+
+  recursive = false;
+endfunction
+
+function update_text (h, d)
+  persistent recursive = false;
+
+  if (!recursive)
+    recursive = true;
+
+    delete (findobj (h, "type", "text"));
+
+    if (strcmpi (get (h, "textlistmode"), "manual"))
+      lvl = get (h, "textlist");
+    elseif (strcmpi (get (h, "textstepmode"), "manual"))
+      lev = get (h, "levellist");
+
+      if (diff (lev) < 10*eps) 
+	lvl_eps = 1e-6;
+      else
+	lvl_eps = min (abs (diff (lev))) / 1000.0;
+      endif
+
+      stp = get (h, "textstep");
+      t = [0, floor(cumsum(diff (lev)) / (abs(stp) - lvl_eps))];
+      lvl = lev([true, t(1:end-1) != t(2:end)]);
+      set (h, "textlist", lvl);
+    else
+      lvl = get (h, "levellist");
+      set (h, "textlist", lvl, "textstep", get (h, "levelstep"));
+    endif
+
+    if (strcmpi (get (h, "showtext"), "on"))
+      switch (get (h, "zlevelmode"))
+	case "manual"
+	  __clabel__ (get (h, "contourmatrix"), lvl, h, 
+		      get (h, "labelspacing"), get (h, "zlevel"));
+	case "auto"
+	  __clabel__ (get (h, "contourmatrix"), lvl, h,
+		      get (h, "labelspacing"), "auto");
+	otherwise
+	  __clabel__ (get (h, "contourmatrix"), lvl, h,
+		      get (h, "labelspacing"), []);
+      endswitch
+    endif
+  endif
+
+  recursive = false;
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__default_plot_options__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,33 @@
+## Copyright (C) 2007, 2009 John W. Eaton
+##
+## 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} {@var{options} =} __default_plot_options__ ()
+## Undocumented internal function.
+## @end deftypefn
+
+## Author: jwe
+
+function options = __default_plot_options__ ()
+
+  options.key = "";
+  options.color = [];
+  options.linestyle = "-";
+  options.marker = "none";
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__errcomm__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,79 @@
+## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Teemu Ikonen
+##
+## 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} {} __errcomm__ (@var{caller}, @var{p}, @dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+## Created: 20.02.2001
+## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
+## Keywords: errorbar, plotting
+
+function retval = __errcomm__ (caller, p, varargin)
+
+  if (nargin < 4)
+    print_usage ();
+  endif
+
+  nargs = length (varargin);
+
+  k = 1;
+  idx = 1;
+  data = cell(6,1);
+  while (k <= nargs)
+    a = varargin{k++};
+    if (isvector (a))
+      a = a(:);
+    elseif (ismatrix (a))
+      ;
+    else
+      usage ("%s (...)", caller);
+    endif
+    sz = size (a);
+    ndata = 1;
+    data{ndata} = a;
+    while (k <= nargs)
+      a = varargin{k++};
+      if (ischar (a) || iscellstr (a))
+	retval(idx++) = __errplot__ (a, p, data{1:ndata});
+	break;
+      elseif (isvector (a))
+	a = a(:);
+      elseif (ismatrix (a))
+	;
+      else
+	error ("wrong argument types");
+      endif
+      if (size (a) != sz)
+	error ("argument sizes do not match");
+      endif
+      data{++ndata} = a;
+      if (ndata > 6)
+	error ("too many arguments to a plot");
+      endif
+    endwhile
+  endwhile
+
+  if (! (ischar (a) || iscellstr (a)))
+    retval(idx++) = __errplot__ ("~", p, data{1:ndata});
+  endif
+
+  drawnow ();
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__errplot__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,180 @@
+## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+##               Teemu Ikonen
+##
+## 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} {@var{h} =} __errplot__ (@var{fstr}, @var{p}, @dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+## Created: 18.7.2000
+## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
+## Keywords: errorbar, plotting
+
+function h = __errplot__ (fstr, p, a1, a2, a3, a4, a5, a6)
+
+  if (nargin < 4 || nargin > 8) # at least two data arguments needed
+    print_usage ();
+  endif
+
+  [fmt, key] = __pltopt__ ("__errplot__", fstr);
+
+  [len, nplots] = size (a1);
+  h = [];
+
+  for i = 1:nplots
+    ## Set the plot type based on linestyle.
+
+    if (strcmp (fmt.linestyle, "~"))
+      ifmt = "yerr";
+    elseif (strcmp (fmt.linestyle, ">"))
+      ifmt = "xerr";
+    elseif (strcmp (fmt.linestyle, "~>"))
+      ifmt = "xyerr";
+    elseif (strcmp (fmt.linestyle, "#"))
+      ifmt = "box";
+    elseif (strcmp (fmt.linestyle, "#~"))
+      ifmt = "boxy";
+    elseif (strcmp (fmt.linestyle, "#~>"))
+      ifmt = "boxxy";
+    else
+      print_usage ();
+    endif
+
+    hg = hggroup ("parent", p);
+    h = [h; hg];
+    args = __add_datasource__ ("__errplot__", hg, 
+			       {"x", "y", "l", "u", "xl", "xu"});
+
+    if (isempty (fmt.color))
+      hl = __line__ (hg, "color", __next_line_color__ ());
+    else
+      hl = __line__ (hg, "color", fmt.color);
+    endif
+
+    ## FIXME -- note the code below adds the errorbar data directly as
+    ## ldata, etc properties of the line objects, as gnuplot can handle
+    ## this.  Matlab has the errorbar part of the plot as a special line
+    ## object with embedded NaNs that draws the three segments of the
+    ## bar separately.  Should we duplicate Matlab's behavior and stop
+    ## using the ldata, etc. properties of the line objects that are
+    ## Octace specific?
+
+    switch (nargin - 2)
+      case 1
+	error ("error plot requires 2, 3, 4 or 6 columns");
+      case 2
+	set (hl, "xdata", (1:len)');
+	set (hl, "ydata", a1(:,i));
+	set (hl, "ldata", a2(:,i));
+	set (hl, "udata", a2(:,i));
+      case 3
+	set (hl, "xdata", a1(:,i));
+	set (hl, "ydata", a2(:,i));
+	set (hl, "ldata", a3(:,i));
+	set (hl, "udata", a3(:,i));
+      case 4
+	set (hl, "xdata", a1(:,i));
+	set (hl, "ydata", a2(:,i));
+
+	if (index (ifmt, "boxxy") || index (ifmt, "xyerr"))
+	  set (hl, "xldata", a3(:,i));
+	  set (hl, "xudata", a3(:,i));
+	  set (hl, "ldata", a4(:,i));
+	  set (hl, "udata", a4(:,i));
+	elseif (index (ifmt, "xerr"))
+	  set (hl, "xldata", a3(:,i));
+	  set (hl, "xudata", a4(:,i));
+	else
+	  set (hl, "ldata", a3(:,i));
+	  set (hl, "udata", a4(:,i));
+	endif
+      case 5
+	error ("error plot requires 2, 3, 4 or 6 columns");
+      case 6
+	set (hl, "xdata", a1(:,i));
+	set (hl, "ydata", a2(:,i));
+	set (hl, "xldata", a3(:,i));
+	set (hl, "xudata", a4(:,i));
+	set (hl, "ldata", a5(:,i));
+	set (hl, "udata", a6(:,i));
+    endswitch
+
+    addproperty ("color", hg, "linecolor", get (hl, "color"));
+    addproperty ("linewidth", hg, "linelinewidth", get (hl, "linewidth"));
+    addproperty ("linestyle", hg, "linelinestyle", get (hl, "linestyle"));
+    addproperty ("marker", hg, "linemarker", get (hl, "marker"));
+    addproperty ("markerfacecolor", hg, "linemarkerfacecolor", 
+		 get (hl, "markerfacecolor"));
+    addproperty ("markeredgecolor", hg, "linemarkerfacecolor", 
+		 get (hl, "markeredgecolor"));
+    addproperty ("markersize", hg, "linemarkersize", 
+		 get (hl, "markersize"));
+
+    addlistener (hg, "color", @update_props);
+    addlistener (hg, "linewidth", @update_props); 
+    addlistener (hg, "linestyle", @update_props); 
+    addlistener (hg, "marker", @update_props); 
+    addlistener (hg, "markerfacecolor", @update_props); 
+    addlistener (hg, "markersize", @update_props);
+
+    addproperty ("xdata", hg, "data", get (hl, "xdata"));
+    addproperty ("ydata", hg, "data", get (hl, "ydata"));
+    addproperty ("ldata", hg, "data", get (hl, "ldata"));
+    addproperty ("udata", hg, "data", get (hl, "udata"));
+    addproperty ("xldata", hg, "data", get (hl, "xldata"));
+    addproperty ("xudata", hg, "data", get (hl, "xudata"));
+
+    addlistener (hg, "xdata", @update_data);
+    addlistener (hg, "ydata", @update_data);
+    addlistener (hg, "ldata", @update_data);
+    addlistener (hg, "udata", @update_data);
+    addlistener (hg, "xldata", @update_data);
+    addlistener (hg, "xudata", @update_data);
+
+    __line__ (hg, "xdata", get (hl, "xdata"), 
+	      "ydata", get (hl, "ydata"), 
+	      "color", get (hl, "color"),
+	      "linewidth", get (hl, "linewidth"),
+	      "linestyle", get (hl, "linestyle"), 
+	      "marker", "none", "parent", hg);
+  endfor
+
+endfunction
+
+function update_props (h, d)
+  set (get (h, "children"), "color", get (h, "color"), 
+       "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"), 
+       "marker", get (h, "marker"), "markersize", get (h, "markersize"),
+       "markerfacecolor", get (h, "markerfacecolor"),
+       "markeredgecolor", get (h, "markeredgecolor"));
+endfunction
+
+function update_data (h, d)
+  x = get (h, "xdata");
+  y = get (h, "ydata");
+  l = get (h, "ldata");
+  u = get (h, "udata");
+  xl = get (h, "xldata");
+  xu = get (h, "xudata");
+
+  kids = get (h, "children");
+  set (kids(1), "xdata", x, "ydata", y);
+  set (kids(2), "xdata", x, "ydata", y, "ldata", l, "udata", u, 
+       "xldata", xl, "xudata", xu);
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__ezplot__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,445 @@
+## Copyright (C) 2007, 2008, 2009 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} {[@var{h}, @var{needusage}] =} __ezplot__ (@var{pfunc}, @var{varargin})
+## Undocumented internal function.
+## @end deftypefn
+
+function [h, needusage] = __ezplot__ (pfunc, varargin)
+
+  func = cstrcat ("ez", pfunc);
+  if (strncmp (pfunc, "contour", 7))
+    iscontour = true;
+  else
+    iscontour = false;
+  endif
+  if (strcmp (pfunc, "plot"))
+    isplot = true;
+    isplot3 = false;
+    ispolar = false;
+    nargs = 1;
+  elseif (strcmp (pfunc, "plot3"))
+    isplot = false;
+    isplot3 = true;
+    ispolar = false;
+    nargs = 1;
+  elseif (strcmp (pfunc, "polar"))
+    isplot = false;
+    isplot3 = false;
+    ispolar = true;
+    nargs = 1;
+  else
+    isplot = false;
+    isplot3 = false;
+    ispolar = false;
+    nargs = 2;
+  endif
+
+  [ax, varargin, nargin] = __plt_get_axis_arg__ (func, varargin{:});
+
+  needusage = false;
+  if (nargin < 1)
+    needusage = true;
+    return;
+  endif
+
+  parametric = false;
+  fun = varargin {1};
+  if (ischar (fun))
+    if (exist (fun, "file") || exist (fun, "builtin"))
+      fun = vectorize (inline (cstrcat (fun, "(t)")));
+    else
+      fun = vectorize (inline (fun));
+    endif
+    if (isplot && length (argnames (fun)) == 2)
+      nargs = 2;
+    elseif (length (argnames (fun)) != nargs)
+      error ("%s: excepting a function of %d arguments", func, nargs);
+    endif
+    fstr = formula (fun);
+    if (isplot)
+      xarg = argnames(fun){1};
+      if (nargs == 2)
+	yarg = argnames(fun){2};
+      else
+	yarg = "";
+      endif
+    elseif (isplot3)
+      xarg = "x";
+      yarg = "y";
+    elseif (ispolar)
+      xarg = "";
+      yarg = "";
+    else
+      xarg = argnames(fun){1};
+      yarg = argnames(fun){2};
+    endif
+  elseif (strcmp (typeinfo (fun), "inline function"))
+    if (isplot && length (argnames (fun)) == 2)
+      nargs = 2;
+    elseif (length (argnames (fun)) != nargs)
+      error ("%s: excepting a function of %d arguments", func, nargs);
+    endif
+    fun = vectorize (fun);
+    fstr = formula (fun);
+    if (isplot)
+      xarg = argnames(fun){1};
+      if (nargs == 2)
+	yarg = argnames(fun){2};
+      else
+	yarg = "";
+      endif
+    elseif (isplot3)
+      xarg = "x";
+      yarg = "y";
+    elseif (isplot || ispolar)
+      xarg = "";
+      yarg = "";
+    else
+      xarg = argnames(fun)(1);
+      yarg = argnames(fun)(2);
+    endif
+  elseif (isa (fun, "function_handle"))
+    fstr = func2str (fun);
+    if (length (findstr (fstr, ")")) != 0)
+      args = regexp (substr (fstr, 3, findstr (fstr, ")")(1) - 3), 
+		     '(\w[\w\d]*)', 'tokens');
+    fstr = substr (fstr, findstr (fstr, ")")(1) + 1);
+    else
+      args = {{"x"}};
+    endif
+    if (isplot && length (args) == 2)
+      nargs = 2;
+    elseif (length (args) != nargs)
+      error ("%s: excepting a function of %d arguments", func, nargs);
+    endif
+    if (isplot)
+      xarg = args{1}{1};
+      if (nargs == 2)
+	yarg = args{2}{1};
+      else
+	yarg = "";
+      endif
+    elseif (isplot3)
+      xarg = "x";
+      yarg = "y";
+    elseif (ispolar)
+      xarg = "";
+      yarg = "";
+    else
+      xarg = args{1}{1};
+      yarg = args{2}{1};
+    endif
+  else
+    error ("%s: expecting string, inline function or function handle", func);
+  endif
+
+  if (nargin > 2 || (nargin == 2 && isplot))
+    funx = fun;
+    fstrx = fstr;
+    funy = varargin {2};
+    if (ischar (funy) && ! strcmp (funy, "circ") && ! strcmp (funy, "animate"))
+      parametric = true;
+      if (exist (funy, "file") || exist (funy, "builtin"))
+	funy = vectorize (inline (cstrcat (funy, "(t)")));
+      else
+	funy = vectorize (inline (funy));
+      endif
+      if (length (argnames (funy)) != nargs)
+	error ("%s: excepting a function of %d arguments", func, nargs);
+      endif
+      fstry = formula (funy);
+    elseif (strcmp (typeinfo (funy), "inline function"))
+      parametric = true;
+      if (length (argnames (funy)) != nargs)
+	error ("%s: excepting a function of %d arguments", func, nargs);
+      endif
+      funy = vectorize (funy);
+      fstry = formula (funy);
+    elseif (isa (funy, "function_handle"))
+      parametric = true;
+      fstry = func2str (funy);
+      if (length (findstr (fstry, ")")) != 0)
+	args = regexp (substr (fstry, 3, findstr (fstry, ")")(1) - 3), 
+		       '(\w[\w\d]*)', 'tokens');
+	fstry = substr (fstry, findstr (fstry, ")")(1) + 1);
+      else
+	args = {{"y"}};
+      endif
+      if (length (args) != nargs)
+	error ("%s: excepting a function of %d arguments", func, nargs);
+      endif
+    endif
+
+    if (parametric && isplot)
+      xarg = "x";
+      yarg = "y";
+      if (nargs == 2)
+	error ("%s: can not define a parametric function in this manner");
+      endif
+    endif
+
+    if (!isplot && parametric)
+      funz = varargin {3};
+      if (ischar (funz) && ! strcmp (funz, "circ") && 
+	  ! strcmp (funz, "animate"))
+	if (exist (funz, "file") || exist (funz, "builtin"))
+	  funz = vectorize (inline (cstrcat (funz, "(t)")));
+	else
+	  funz = vectorize (inline (funz));
+	endif
+	if (length (argnames (funz)) != nargs)
+	  error ("%s: excepting a function of %d arguments", func, nargs);
+	endif
+	fstrz = formula (funz);
+      elseif (strcmp (typeinfo (funz), "inline function"))
+	if (length (argnames (funz)) != nargs)
+	  error ("%s: excepting a function of %d arguments", func, nargs);
+	endif
+	funz = vectorize (funz);
+	fstrz = formula (funz);
+      elseif (isa (funz, "function_handle"))
+	fstrz = func2str (funz);
+	args = regexp (substr (fstrz, 3, findstr (fstrz, ")")(1) - 3), 
+		       '(\w[\w\d]*)', 'tokens');
+	if (length (args) != nargs)
+	  error ("%s: excepting a function of %d arguments", func, nargs);
+	endif
+	fstrz = substr (fstrz, findstr (fstrz, ")")(1) + 1);
+      else
+	error ("%s: parametric plots expect 3 functions", func);
+      endif
+    endif
+  endif
+
+  if (isplot && nargs != 2)
+    n = 500; 
+  else
+    n = 60;
+  endif
+  domain = [];
+  circ = false;
+  animate = false;
+  if (parametric)
+    if (isplot)
+      iarg = 3;
+    else
+      iarg = 4;
+    endif
+  else
+    iarg = 2;
+  endif
+  while (iarg <= nargin)
+    arg = varargin{iarg++};
+    if (ischar (arg) && strcmp (arg, "circ"))
+      circ = true;
+    elseif (ischar (arg) && strcmp (arg, "animate"))
+      animate = true;
+    elseif (isscalar (arg))
+      n = arg;
+    elseif (numel (arg) == 2)
+      domain = [arg(:).' arg(:).'];
+    elseif (numel (arg) == 4)
+      domain = arg(:).';
+    else
+      error ("%s: expecting scalar, 2 or 4 element vector", func);
+    endif
+  endwhile
+
+  if (isempty (domain))
+    if (isplot3 || ispolar)
+      domain = [0, 2*pi, 0, 2*pi];
+    else
+      domain = [-2*pi, 2*pi, -2*pi, 2*pi];
+    endif
+  endif
+
+  if (circ)
+    if (iscontour || isplot3 || isplot)
+      needusage = true;
+      return;
+    endif
+    if (parametric)
+      error ("%s: can not have both circular domain and parametric function", 
+	     func);
+    endif
+    cent = [domain(1) + domain(2), domain(3) + domain(4)] / 2;
+    funx = @(r,t) r .* cos (t) + cent (1);
+    funy = @(r,t) r .* sin (t) + cent (2);
+    domain = [0, sqrt((domain(2) - cent(1))^2 + (domain(4) - cent(2))^2), ...
+	      -pi, pi];
+    funz = fun;
+    parametric = true;
+  endif
+
+  if (animate)
+    if (!isplot3)
+      error ("%s: animated graphs only valid with plot3", func);
+    endif
+    error ("%s: animated graphs not implemented", func);
+  endif
+
+  if (isplot3 || ispolar || (isplot && nargs == 1))
+    X = linspace (domain (1), domain (2), n);
+  elseif (isplot && numel (domain) == 2)
+    x = linspace (domain (1), domain (2), n);
+    [X, Y] = meshgrid (x, x);
+  else
+    x = linspace (domain (1), domain (2), n);
+    y = linspace (domain (3), domain (4), n);
+    [X, Y] = meshgrid (x, y);
+  endif
+
+  if (parametric)
+    if (isplot)
+      XX = feval (funx, X);
+      Z = feval (funy, X);
+      X = XX;
+    elseif (isplot3)
+      Z = feval (funz, X);
+      XX = feval (funx, X);
+      YY = feval (funy, X);
+      X = XX;
+      Y = YY;
+    else
+      Z = feval (funz, X, Y);
+      XX = feval (funx, X, Y);
+      YY = feval (funy, X, Y);
+      X = XX;
+      Y = YY;
+
+      ## Eliminate the singularities
+      X = __eliminate_sing__ (X);
+      Y = __eliminate_sing__ (Y);
+      Z = __eliminate_sing__ (Z);
+    endif
+
+    fstrx = regexprep (regexprep (regexprep (fstrx,'\.\^\s*','^'), 
+		      '\./', '/'), '[\.]*\*', '');
+    fstry = regexprep (regexprep (regexprep (fstry,'\.\^\s*','^'), 
+		      '\./', '/'), '[\.]*\*', '');
+    if (isplot)
+      fstr = cstrcat ("x = ",fstrx,", y = ",fstry);
+    else
+      fstrz = regexprep (regexprep (regexprep (fstrz,'\.\^\s*','^'), 
+				    '\./', '/'), '[\.]*\*', '');
+      fstr = cstrcat ("x = ",fstrx,",y = ",fstry,", z = ",fstrz);
+    endif
+  else
+    if (isplot3)
+      needusage = true;
+      return;
+    endif
+
+    fstr = regexprep (regexprep (regexprep (fstr,'\.\^\s*','^'), '\./', '/'), 
+		      '[\.]*\*', '');
+    if (isplot && nargs == 2)
+      if (strcmp (typeinfo (fun), "inline function") && 
+	  !isempty (strfind (formula (fun) , "=")))
+	fun = inline (cstrcat (strrep (formula (fun), "=", "- ("), ")"));
+      else
+	fstr = cstrcat (fstr, " = 0");
+      endif
+
+      Z = feval (fun, X, Y);
+
+      ## Matlab returns line objects for this case and so can't call 
+      ## contour directly as it returns patch objects to allow colormaps
+      ## to work with contours. Therefore recreate the lines from the
+      ## output for contourc, and store in cell arrays.
+      [c, lev] = contourc (X, Y, Z, [0, 0]);
+
+      i1 = 1;
+      XX = {};
+      YY = {};
+      while (i1 < length (c))
+	clev = c(1,i1);
+	clen = c(2,i1);
+	XX = [XX, {c(1, i1+1:i1+clen)}];
+	YY = [YY, {c(2, i1+1:i1+clen)}];
+	i1 += clen+1;
+      endwhile
+    else  
+      if (ispolar)
+	Z = feval (fun, X);
+      elseif (isplot)
+	Z = real (feval (fun, X));
+
+	## Eliminate the singularities. This seems to be what matlab
+	## does, but can't be sure.
+	XX = sort (Z (isfinite (Z)));
+	if (length (X) > 4)
+	  d = XX(fix (7 * length (XX) / 8)) - XX(fix (length (XX) / 8));
+	  yrange = [max(XX(1) - d/8, XX(fix (length (XX) / 8)) - d), ...
+		    min(XX(end) + d/8, XX(fix (7 * length (XX) / 8)) + d)];
+	else
+	  yrange = [XX(1), XX(end)];
+        endif
+
+	idx = 2 : length(Z);
+	idx = find (((Z(idx) > yrange(2) / 2) & (Z(idx-1) < yrange(1) / 2)) |
+		 ((Z(idx) < yrange(1) / 2) & (Z(idx-1) > yrange (2) / 2)));
+	if (any(idx))
+	  Z(idx) = NaN; 
+	endif
+      else
+	Z = feval (fun, X, Y);
+
+	## Eliminate the singularities
+	Z = __eliminate_sing__ (Z);
+      endif
+    endif
+  endif
+
+  oldax = gca (); 
+  unwind_protect
+    axes (ax);
+    if (iscontour)
+      [clev, h] = feval (pfunc, X, Y, Z);
+    elseif (isplot && nargs == 2)
+      h = [];
+      hold_state = get (ax, "nextplot");
+      for i = 1 : length (XX)
+	h = [h; plot(XX{i}, YY{i})];
+	if (i == 1)
+	  set (ax, "nextplot", "add")
+	endif
+      endfor
+      set (ax, "nextplot", hold_state)
+    elseif (ispolar || isplot)
+      h = feval (pfunc, X, Z);
+      if (isplot && !parametric)
+	axis ([X(1), X(end), yrange]);
+      endif
+    else
+      h = feval (pfunc, X, Y, Z);
+    endif
+    xlabel (xarg);
+    ylabel (yarg);
+    title (fstr);
+  unwind_protect_cleanup
+    axes (oldax);
+  end_unwind_protect
+
+endfunction
+
+function x = __eliminate_sing__ (x)
+  x (isinf (x)) = NaN;
+  x (abs (del2 (x)) > 0.2 * (max(x(:)) - min(x(:)))) = NaN;
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__interp_cube__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,181 @@
+## Copyright (C) 2009 Martin Helm
+##
+## This program 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.
+##
+## This program 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 this program; if not, see http://www.gnu.org/licenses/gpl.html.
+##
+## Author: Martin Helm <martin@mhelm.de>
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {[@var{vxyz}, @var{idx}, @var{frac}] =} __interp_cube__ (@var{x}, @var{y}, @var{z}, @var{val}, @var{v})
+## Undocumented internal function.
+## @end deftypefn
+
+function [Vxyz, idx, frac] = __interp_cube__(x, y, z, val, v, req = "values" )
+  if (ismatrix (x) && ndims (x) == 3 && ismatrix (y) && ndims (y) == 3 ...
+       && ismatrix (z) && ndims (z) == 3 && size_equal (x, y, z, val))
+    x = squeeze (x(1,:,1))(:);
+    y = squeeze (y(:,1,1))(:);
+    z = squeeze (z(1,1,:))(:);
+  elseif (isvector (x) && isvector (y) && isvector (z) )
+    x = x(:);
+    y = y(:);
+    z = z(:);
+  else
+    error("x, y, z have wrong dimensions");
+  endif
+  if (size (val) != [length(x), length(y), length(z)])
+    error ("val has wrong dimensions");
+  endif
+  if (size (v, 2) != 3)
+    error ( "v has to be N*3 matrix");
+  endif
+  if (!ischar (req))
+   error ("Invalid request parameter use 'values', 'normals' or 'normals8'");
+  endif
+  if (isempty (v))
+    Vxyz = idx = frac = [];
+    return
+  endif
+
+  switch req
+    case "values"
+      [Vxyz, idx, frac] = interp_cube_trilin (x, y, z, val, v);
+    case "normals"
+      [idx, frac] = cube_idx (x, y, z, v);
+
+      dx = x(2:end) - x(1:end-1);
+      dy = y(2:end) - y(1:end-1);
+      dz = z(2:end) - z(1:end-1);
+      dx = 0.5 .* [dx;dx(end)](idx(:,2));
+      dy = 0.5 .* [dy;dy(end)](idx(:,1));
+      dz = 0.5 .* [dz;dz(end)](idx(:,3));
+
+      p000 = [v(:, 1) - dx, v(:, 2) - dy, v(:, 3) - dz];
+      p100 = [v(:, 1) + dx, v(:, 2) - dy, v(:, 3) - dz];
+      p010 = [v(:, 1) - dx, v(:, 2) + dy, v(:, 3) - dz];
+      p001 = [v(:, 1) - dx, v(:, 2) - dy, v(:, 3) + dz];
+      p011 = [v(:, 1) - dx, v(:, 2) + dy, v(:, 3) + dz];
+      p101 = [v(:, 1) + dx, v(:, 2) - dy, v(:, 3) + dz];
+      p110 = [v(:, 1) + dx, v(:, 2) + dy, v(:, 3) - dz];
+      p111 = [v(:, 1) + dx, v(:, 2) + dy, v(:, 3) + dz];
+
+      v000 = interp_cube_trilin (x, y, z, val, p000);
+      v100 = interp_cube_trilin (x, y, z, val, p100);
+      v010 = interp_cube_trilin (x, y, z, val, p010);
+      v001 = interp_cube_trilin (x, y, z, val, p001);
+      v011 = interp_cube_trilin (x, y, z, val, p011);
+      v101 = interp_cube_trilin (x, y, z, val, p101);
+      v110 = interp_cube_trilin (x, y, z, val, p110);
+      v111 = interp_cube_trilin (x, y, z, val, p111);
+
+      Dx = -v000 .+ v100 .- v010 .- v001 .- v011 .+ v101 .+ v110 .+ v111;
+      Dy = -v000 .- v100 .+ v010 .- v001 .+ v011 .- v101 .+ v110 .+ v111;
+      Dz = -v000 .- v100 .- v010 .+ v001 .+ v011 .+ v101 .- v110 .+ v111;
+      Vxyz = 0.5 .* [Dx./dx, Dy./dy, Dz./dz];
+    case "normals8"
+      [idx, frac] = cube_idx (x, y, z, v);
+
+      dx = x(2:end) - x(1:end-1);
+      dy = y(2:end) - y(1:end-1);
+      dz = z(2:end) - z(1:end-1);
+      dx = [dx;dx(end)](idx(:,2));
+      dy = [dy;dy(end)](idx(:,1));
+      dz = [dz;dz(end)](idx(:,3));
+      [Dx, Dy, Dz, idx, frac] = interp_cube_trilin_grad (x, y, z, val, v);
+      Vxyz = [Dx./dx, Dy./dy, Dz./dz];
+   otherwise
+     error ("Invalid request type '%s', use 'values', 'normals' or 'normals8'", req);
+  endswitch
+endfunction
+
+function [Vxyz, idx, frac] = interp_cube_trilin(x, y, z, val, v)
+  [idx, frac] = cube_idx (x(:), y(:), z(:), v);
+  sval = size (val);
+  i000 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3));
+  i100 = sub2ind (sval, idx(:, 1)+1, idx(:, 2), idx(:, 3));
+  i010 = sub2ind (sval, idx(:, 1), idx(:, 2)+1, idx(:, 3));
+  i001 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3)+1);
+  i101 = sub2ind (sval, idx(:, 1)+1, idx(:, 2), idx(:, 3)+1);
+  i011 = sub2ind (sval, idx(:, 1), idx(:, 2)+1, idx(:, 3)+1);
+  i110 = sub2ind (sval, idx(:, 1)+1, idx(:, 2)+1, idx(:, 3));
+  i111 = sub2ind (sval, idx(:, 1)+1, idx(:, 2)+1, idx(:, 3)+1 );
+  Bx = frac(:, 1);
+  By = frac(:, 2);
+  Bz = frac(:, 3);
+  Vxyz = ...
+    val( i000 ) .* (1 .- Bx) .* (1 .- By) .* (1 .- Bz) .+ ...
+    val( i100 ) .* Bx .* (1 .- By) .* (1 .- Bz) .+ ...
+    val( i010 ) .* (1 .- Bx) .* By .* (1 .- Bz) .+ ...
+    val( i001 ) .* (1 .- Bx) .* (1 .- By) .* Bz .+ ...
+    val( i011 ) .* (1 .- Bx) .* By .* Bz .+ ...
+    val( i101 ) .* Bx .* (1 .- By) .* Bz .+ ...
+    val( i110 ) .* Bx .* By .* (1 .- Bz) .+ ...
+    val( i111 ) .* Bx .* By .* Bz;
+endfunction
+
+function [Dx, Dy, Dz, idx, frac] = interp_cube_trilin_grad(x, y, z, val, v)
+  [idx, frac] = cube_idx (x(:), y(:), z(:), v);
+  sval = size (val);
+  i000 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3));
+  i100 = sub2ind (sval, idx(:, 1)+1, idx(:, 2), idx(:, 3));
+  i010 = sub2ind (sval, idx(:, 1), idx(:, 2)+1, idx(:, 3));
+  i001 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3)+1);
+  i101 = sub2ind (sval, idx(:, 1)+1, idx(:, 2), idx(:, 3)+1);
+  i011 = sub2ind (sval, idx(:, 1), idx(:, 2)+1, idx(:, 3)+1);
+  i110 = sub2ind (sval, idx(:, 1)+1, idx(:, 2)+1, idx(:, 3));
+  i111 = sub2ind (sval, idx(:, 1)+1, idx(:, 2)+1, idx(:, 3)+1 );
+  Bx = frac(:, 1);
+  By = frac(:, 2);
+  Bz = frac(:, 3);
+  Dx = ...
+    val( i000 ) .* -1 .* (1 .- By) .* (1 .- Bz) .+ ...
+    val( i100 ) .* (1 .- By) .* (1 .- Bz) .+ ...
+    val( i010 ) .* -1 .* By .* (1 .- Bz) .+ ...
+    val( i001 ) .* -1 .* (1 .- By) .* Bz .+ ...
+    val( i011 ) .* -1 .* By .* Bz .+ ...
+    val( i101 ) .* (1 .- By) .* Bz .+ ...
+    val( i110 ) .* By .* (1 .- Bz) .+ ...
+    val( i111 ) .* By .* Bz;
+  Dy = ...
+    val( i000 ) .* (1 .- Bx) .* -1 .* (1 .- Bz) .+ ...
+    val( i100 ) .* Bx .* -1 .* (1 .- Bz) .+ ...
+    val( i010 ) .* (1 .- Bx) .* (1 .- Bz) .+ ...
+    val( i001 ) .* (1 .- Bx) .* -1 .* Bz .+ ...
+    val( i011 ) .* (1 .- Bx) .* Bz .+ ...
+    val( i101 ) .* Bx .* -1 .* Bz .+ ...
+    val( i110 ) .* Bx .* (1 .- Bz) .+ ...
+    val( i111 ) .* Bx .* Bz;
+  Dz = ...
+    val( i000 ) .* (1 .- Bx) .* (1 .- By) .* -1 .+ ...
+    val( i100 ) .* Bx .* (1 .- By) .* -1 .+ ...
+    val( i010 ) .* (1 .- Bx) .* By .* -1 .+ ...
+    val( i001 ) .* (1 .- Bx) .* (1 .- By) .+ ...
+    val( i011 ) .* (1 .- Bx) .* By + ...
+    val( i101 ) .* Bx .* (1 .- By) .+ ...
+    val( i110 ) .* Bx .* By .* -1 .+ ...
+    val( i111 ) .* Bx .* By;
+endfunction
+
+function [idx, frac] = cube_idx(x, y, z, v)
+  idx = zeros (size (v));
+  frac = zeros (size (v));
+  idx(:, 2) = lookup (x(2:end-1), v(:, 1)) + 1;
+  frac(:, 2) = (v(:, 1) - x(idx(:, 2)) )...
+      ./ (x(idx(:, 2)+1) - x(idx(:, 2)));
+  idx(:, 1) = lookup (y(2:end-1), v(:, 2)) + 1;
+  frac(:, 1) = (v(:, 2) - y(idx(:, 1))) ...
+      ./ (y(idx(:, 1)+1) - y(idx(:, 1)));
+  idx(:, 3) = lookup (z(2:end-1), v(:, 3)) + 1;
+  frac(:, 3) = (v(:, 3) - z(idx(:, 3))) ...
+      ./ (z(idx(:, 3)+1) - z(idx(:, 3)));
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__line__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,67 @@
+## Copyright (C) 2005, 2007, 2008, 2009 John W. Eaton
+##
+## 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} {@var{h} =} __line__ (@var{p}, @dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+## __line__ (p, x, y, z)
+## Create line object from x, y, and z with parent p.
+## Return handle to line object.
+
+## Author: jwe
+
+function h = __line__ (p, varargin)
+
+  if (nargin < 1)
+    print_usage ();
+  endif
+
+  nvargs = numel (varargin);
+
+  if (nvargs > 1 && isnumeric (varargin{1}) && isnumeric (varargin{2}))
+    if (nvargs > 2 && isnumeric (varargin{3}))
+      num_data_args = 3;
+    else
+      num_data_args = 2;
+    endif
+  else
+    num_data_args = 0;
+  endif
+
+  if (rem (nvargs - num_data_args, 2) != 0)
+    print_usage ("line");
+  endif
+
+  data_args = {};
+  if (num_data_args > 1)
+    data_args(1:4) = { "xdata", varargin{1}, "ydata", varargin{2} };
+    if (num_data_args == 3)
+      data_args(5:6) = { "zdata", varargin{3} };
+    endif
+  endif
+
+  other_args = {};
+  if (nvargs > num_data_args)
+    other_args = varargin(num_data_args+1:end);
+  endif
+
+  h = __go_line__ (p, data_args{:}, other_args{:});
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__patch__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,316 @@
+## Copyright (C) 2007, 2008, 2009 John W. Eaton, Shai Ayal, Kai Habel
+##
+## 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} {[@var{h}, @var{fail}] =} __patch__ (@var{p}, @dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+## __patch__ (p, x, y, c)
+## Create patch object from x and y with color c and parent p.
+## Return handle to patch object.
+
+## Author: Kai Habel
+
+function [h, failed] = __patch__ (p, varargin)
+
+  failed = false;
+
+  if (isstruct (varargin{1}))
+    if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces"))
+      args{1} = "faces";
+      args{2} = getfield(varargin{1}, "faces");
+      args{3} = "vertices";
+      args{4} = getfield(varargin{1}, "vertices");
+      args{5} = "facevertexcdata";
+      if (isfield (varargin{1}, "facevertexcdata"))
+	args{6} = getfield(varargin{1}, "facevertexcdata");
+      else
+	args{6} = [];
+      endif
+      args = [args; varargin(2:end)];
+      args = setdata (args);
+    else
+      failed = true;
+    endif
+  elseif (isnumeric (varargin{1}))
+    if (nargin < 3 || ! isnumeric (varargin{2}))
+      failed = true;
+    else
+      x = varargin{1};
+      y = varargin{2};
+      iarg = 3;
+
+      if (nargin > 3 && ndims (varargin{3}) == 2 && ndims (x) == 2
+	  && size_equal(x, varargin{3}) && !ischar(varargin{3}))
+	z = varargin{3};
+	iarg++;
+      else
+	z = [];
+      endif
+
+      if (isvector (x))
+	x = x(:);
+	y = y(:);
+	z = z(:);
+      endif
+      args{1} = "xdata";
+      args{2} = x;
+      args{3} = "ydata";
+      args{4} = y;
+      args{5} = "zdata";
+      args{6} = z;
+
+      if (isnumeric (varargin{iarg}))
+	c = varargin{iarg};
+	iarg++;
+
+	if (ndims (c) == 3 && size (c, 2) == 1)
+	  c = permute (c, [1, 3, 2]);
+	endif
+
+	if (isvector (c) && numel (c) == columns (x))
+	  if (isnan (c))
+	    args{7} = "facecolor";
+	    args{8} = [1, 1, 1];
+	    args{9} = "cdata";
+	    args{10} = c;
+	  elseif (isnumeric (c))
+	    args{7} = "facecolor";
+	    args{8} = "flat";
+	    args{9} = "cdata";
+	    args{10} = c;
+	  else
+	    error ("patch: color value not valid");
+	  endif
+	elseif (size (c, ndims (c)) == 3)
+	  args{7} = "facecolor";
+	  args{8} = "flat";
+	  args{9} = "cdata";
+	  args{10} = c;
+	else
+	  ## Color Vectors
+	  if (rows (c) != rows (x) || rows (c) != length (y))
+	    error ("patch: size of x, y, and c must be equal")
+	  else
+	    args{7} = "facecolor";
+	    args{8} = "interp";
+	    args{9} = "cdata";
+	    args{10} = [];
+	  endif
+	endif
+      elseif (ischar (varargin{iarg}) && rem (nargin - iarg, 2) != 0)
+	## Assume that any additional argument over an even number is
+	## color string.
+	args{7} = "facecolor";
+	args{8} =  tolower (varargin{iarg});
+	args{9} = "cdata";
+	args{10} = [];
+	iarg++;
+      else
+	args{7} = "facecolor";
+	args{8} = [0, 1, 0];
+	args{9} = "cdata";
+	args{10} = [];
+      endif
+
+      args = [args, varargin(iarg:end)];
+      args = setvertexdata (args);
+    endif
+  else
+    args = varargin;
+    if (any(cellfun (@(x) strcmpi(x,"faces") || strcmpi(x, "vertices"), args)))
+      args = setdata (args);
+    else
+      args = setvertexdata (args);
+    endif
+  endif
+
+  if (!failed)
+    h = __go_patch__ (p, args {:});
+
+    ## Setup listener functions
+    addlistener (h, "xdata", @update_data);
+    addlistener (h, "ydata", @update_data);
+    addlistener (h, "zdata", @update_data);
+    addlistener (h, "cdata", @update_data);
+
+    addlistener (h, "faces", @update_fvc);
+    addlistener (h, "vertices", @update_fvc);
+    addlistener (h, "facevertexcdata", @update_fvc);
+  endif
+endfunction
+
+function args = delfields(args, flds)
+  idx = cellfun (@(x) any (strcmpi (x, flds)), args);
+  idx = idx | [false, idx(1:end-1)];
+  args (idx) = [];
+endfunction
+
+function args = setdata (args)
+  args = delfields (args, {"xdata", "ydata", "zdata", "cdata"});
+  nargs = length (args);
+  idx = find (cellfun (@(x) strcmpi (x, "faces"), args)) + 1;
+  if (idx > nargs)
+    faces = [];
+  else
+    faces = args {idx};
+  endif
+  idx = find (cellfun (@(x) strcmpi (x, "vertices"), args)) + 1;
+  if (idx > nargs)
+    vert = [];
+  else
+    vert = args {idx};
+  endif
+  idx = find (cellfun (@(x) strcmpi (x, "facevertexcdata"), args)) + 1;
+  if (isempty(idx) || idx > nargs)
+    fvc = [];
+  else
+    fvc = args {idx};
+  endif
+  idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args)) + 1;
+  if (isempty(idx) || idx > nargs)
+    if (!isempty (fvc))
+      fc = "flat";
+    else
+      fc = [0, 1, 0];
+    endif
+    args = {"facecolor", fc, args{:}};
+  else
+    fc = args {idx};
+  endif
+
+  nr = size (faces, 2);
+  nc = size (faces, 1);
+  idx = faces .';
+  t1 = isnan (idx);
+  if (any (t1(:)))
+    t2 = find (t1 != t1([2:end,end],:));
+    idx (t1) = idx (t2 (cell2mat (cellfun (@(x) x(1)*ones(1,x(2)),
+		mat2cell ([1 : nc; sum(t1)], 2, ones(1,nc)), 
+					   "UniformOutput", false))));
+  endif
+  x = reshape (vert(:,1)(idx), size (idx));
+  y = reshape (vert(:,2)(idx), size (idx));
+  if (size(vert,2) > 2)
+    z = reshape (vert(:,3)(idx), size (idx));
+  else
+    z = [];
+  endif
+
+  if (ischar (fc) && (strcmpi (fc, "flat") || strcmpi (fc, "interp")))
+    if (size(fvc, 1) == nc || size (fvc, 1) == 1)
+      c = reshape (fvc, [1, size(fvc)]);
+    else
+      if (size(fvc, 2) == 3)
+	c = cat(3, reshape (fvc(idx, 1), size(idx)),
+		reshape (fvc(idx, 2), size(idx)),
+		reshape (fvc(idx, 3), size(idx)));
+      else
+	c = reshape (fvc(idx), size(idx));
+      endif
+    endif
+  else
+    c = [];
+  endif
+  args = {"xdata", x, "ydata", y, "zdata", z, "cdata", c, args{:}};
+endfunction
+
+function args = setvertexdata (args)
+  args = delfields (args, {"vertices", "faces", "facevertexcdata"});
+  nargs = length (args);
+  idx = find (cellfun (@(x) strcmpi (x, "xdata"), args)) + 1;
+  if (idx > nargs)
+    x = [];
+  else
+    x = args {idx};
+  endif
+  idx = find (cellfun (@(x) strcmpi (x, "ydata"), args)) + 1;
+  if (idx > nargs)
+    y = [];
+  else
+    y = args {idx};
+  endif
+  idx = find (cellfun (@(x) strcmpi (x, "zdata"), args)) + 1;
+  if (isempty(idx) || idx > nargs)
+    z = [];
+  else
+    z = args {idx};
+  endif
+  idx = find (cellfun (@(x) strcmpi (x, "cdata"), args)) + 1;
+  if (isempty(idx) || idx > nargs)
+    c = [];
+  else
+    c = args {idx};
+  endif
+  idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args)) + 1;
+  if (isempty(idx) || idx > nargs)
+    if (!isempty (c))
+      fc = "flat";
+    else
+      fc = [0, 1, 0];
+    endif
+    args = {"facecolor", fc, args{:}};
+  else
+    fc = args {idx};
+  endif
+
+  [nr, nc] = size (x);
+  if (!isempty (z))
+    vert = [x(:), y(:), z(:)];
+  else
+    vert = [x(:), y(:)];
+  endif
+  faces = reshape (1:numel(x), rows (x), columns (x));
+  faces = faces';
+
+  if (ischar (fc) && (strcmpi (fc, "flat") || strcmpi (fc, "interp")))
+    if (ndims (c) == 3)
+      fvc = reshape (c, size (c, 1) * size (c, 2), size(c, 3));
+    else
+      fvc = c(:);
+    endif
+  else
+    fvc = [];
+  endif
+
+  args = {"faces", faces, "vertices", vert, "facevertexcdata", fvc, args{:}};
+endfunction
+
+function update_data (h, d)
+  update_handle (h, false);
+endfunction
+
+function update_fvc (h, d)
+  update_handle (h, true);
+endfunction
+
+function update_handle (h, isfv)
+  persistent recursive = false;
+
+  if (! recursive)
+    recursive = true;
+    f = get (h);
+    if (isfvc)
+      set (h, setvertexdata ([fieldnames(f), struct2cell(f)].'(:)){:});
+    else
+      set (h, setdata ([fieldnames(f), struct2cell(f)].'(:)){:});
+    endif
+    recursive = false;
+  endif
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__plt__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,559 @@
+## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2004,
+##               2005, 2006, 2007, 2009 John W. Eaton
+##
+## 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} {} __plt__ (@var{caller}, @var{h}, @var{varargin})
+## Undocumented internal function.
+## @end deftypefn
+
+## Author: jwe
+
+function retval = __plt__ (caller, h, varargin)
+
+  nargs = nargin - 2;
+
+  if (nargs > 0)
+
+    k = 1;
+
+    x_set = false;
+    y_set = false;
+    property_set = false;
+    properties = {};
+
+    ## Gather arguments, decode format, gather plot strings, and plot lines.
+
+    retval = [];
+
+    while (nargs > 0 || x_set)
+
+      if (nargs == 0)
+	## Force the last plot when input variables run out.
+	next_cell = {};
+	next_arg = {""};
+      else
+	next_cell = varargin(k);
+	next_arg = varargin{k++};
+      endif
+
+      nargs--;
+
+      if (ischar (next_arg) || iscellstr (next_arg))
+	if (x_set)
+	  [options, valid] = __pltopt__ (caller, next_arg, false);
+	  if (! valid)
+	    if (nargs == 0)
+	      error ("%s: properties must appear followed by a value", caller);
+	    endif
+	    properties = [properties, [next_cell, varargin(k++)]];
+	    nargs--;
+	    continue;
+	  else
+	    while (nargs > 0 && ischar (varargin{k}))
+	      if (nargs < 2)
+		error ("%s: properties must appear followed by a value",
+		       caller);
+	      endif
+	      properties = [properties, varargin(k:k+1)];
+	      k += 2;
+	      nargs -= 2;
+	    endwhile
+	  endif
+	  if (y_set)
+	    tmp = __plt2__ (h, x, y, options, properties);
+	    properties = {};
+	    retval = [retval; tmp];
+	  else
+	    tmp = __plt1__ (h, x, options, properties);
+	    properties = {};
+	    retval = [retval; tmp];
+	  endif
+	  x_set = false;
+	  y_set = false;
+	else
+	  error ("plot: no data to plot");
+	endif
+      elseif (x_set)
+	if (y_set)
+	  options = __pltopt__ (caller, {""});
+	  tmp = __plt2__ (h, x, y, options, properties);
+	  retval = [retval; tmp];
+	  x = next_arg;
+	  y_set = false;
+	  properties = {};
+	else
+	  y = next_arg;
+	  y_set = true;
+	endif
+      else
+	x = next_arg;
+	x_set = true;
+      endif
+
+    endwhile
+
+  else
+    msg = sprintf ("%s (y)\n", caller);
+    msg = sprintf ("%s       %s (x, y, ...)\n", msg, caller);
+    msg = sprintf ("%s       %s (x, y, fmt, ...)", msg, caller);
+    msg = sprintf ("%s       %s (x, y, property, value, ...)", msg, caller);
+    usage (msg);
+  endif
+
+endfunction
+  
+function retval = __plt1__ (h, x1, options, properties)
+
+  if (nargin < 2 || nargin > 4)
+    print_usage ();
+  endif
+
+  if (nargin < 3 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 4)
+    properties = {};
+  endif
+
+  if (! isstruct (options))
+    error ("__plt1__: options must be a struct array");
+  endif
+
+  [nr, nc] = size (x1);
+  if (nr == 1)
+    x1 = x1.';
+    tmp = nr;
+    nr = nc;
+    nc = tmp;
+  endif
+  x1_i = imag (x1);
+  if (any (any (x1_i)))
+    x2 = x1_i;
+    x1 = real (x1);
+  else
+    x2 = x1;
+    x1 = (1:nr)';
+  endif
+
+  retval = __plt2__ (h, x1, x2, options, properties);
+
+endfunction
+
+function retval = __plt2__ (h, x1, x2, options, properties)
+
+  if (nargin < 3 || nargin > 5)
+    print_usage ();
+  endif
+
+  if (nargin < 4 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 5)
+    properties = {};
+  endif
+
+  if (! isstruct (options))
+    error ("__plt1__: options must be a struct array");
+  endif
+
+  if (any (any (imag (x1))))
+    x1 = real (x1);
+  endif
+
+  if (any (any (imag (x2))))
+    x2 = real (x2);
+  endif
+
+  h_set = false;
+  if (isempty (x1) && isempty (x2))
+    retval = zeros (0, 1);
+  elseif (isscalar (x1))
+    if (isscalar (x2))
+      retval = __plt2ss__ (h, x1, x2, options, properties);
+    elseif (isvector (x2))
+      retval = __plt2sv__ (h, x1, x2, options, properties);
+    else
+      error ("__plt2__: invalid data for plotting");
+    endif
+  elseif (isvector (x1))
+    if (isscalar (x2))
+      retval = __plt2vs__ (h, x1, x2, options, properties);
+    elseif (isvector (x2))
+      retval = __plt2vv__ (h, x1, x2, options, properties);
+    elseif (ismatrix (x2))
+      retval = __plt2vm__ (h, x1, x2, options, properties);
+    else
+      error ("__plt2__: invalid data for plotting");
+    endif
+  elseif (ismatrix (x1))
+    if (isvector (x2))
+      retval = __plt2mv__ (h, x1, x2, options, properties);
+    elseif (ismatrix (x2))
+      retval = __plt2mm__ (h, x1, x2, options, properties);
+    else
+      error ("__plt2__: invalid data for plotting");
+    endif
+  else
+    error ("__plt2__: invalid data for plotting");
+  endif
+
+endfunction
+
+function retval = __plt2mm__ (h, x, y, options, properties)
+
+  if (nargin < 3 || nargin > 5)
+    print_usage ();
+  endif
+
+  if (nargin < 4 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 5)
+    properties = {};
+  endif
+
+  [x_nr, x_nc] = size (x);
+  [y_nr, y_nc] = size (y);
+
+  k = 1;
+  if (x_nr == y_nr && x_nc == y_nc)
+    if (x_nc > 0)
+      if (numel (options) == 1)
+	options = repmat (options(:), x_nc, 1);
+      endif
+      retval = zeros (x_nc, 1);
+      for i = 1:x_nc
+	tkey = options(i).key;
+	if (! isempty (tkey))
+	  set (h, "key", "on");
+	endif
+	color = options(i).color;
+	if (isempty (color))
+	  color = __next_line_color__ ();
+	endif
+
+	retval(i) = line (x(:,i), y(:,i), "keylabel", tkey, "color", color,
+			  "linestyle", options(i).linestyle,
+			  "marker", options(i).marker, properties{:});
+      endfor
+    else
+      error ("__plt2mm__: arguments must be a matrices");
+    endif
+  else
+    error ("__plt2mm__: matrix dimensions must match");
+  endif
+
+endfunction
+
+function retval = __plt2mv__ (h, x, y, options, properties)
+
+  if (nargin < 3 || nargin > 5)
+    print_usage ();
+  endif
+
+  if (nargin < 4 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 5)
+    properties = {};
+  endif
+
+  [x_nr, x_nc] = size (x);
+  [y_nr, y_nc] = size (y);
+
+  if (y_nr == 1)
+    y = y';
+    tmp = y_nr;
+    y_nr = y_nc;
+    y_nc = tmp;
+  endif
+
+  if (x_nr == y_nr)
+    1;
+  elseif (x_nc == y_nr)
+    x = x';
+    tmp = x_nr;
+    x_nr = x_nc;
+    x_nc = tmp;
+  else
+    error ("__plt2mv__: matrix dimensions must match");
+  endif
+
+  if (x_nc > 0)
+    if (numel (options) == 1)
+      options = repmat (options(:), x_nc, 1);
+    endif
+    retval = zeros (x_nc, 1);
+    for i = 1:x_nc
+      tkey = options(i).key;
+      if (! isempty (tkey))
+	set (h, "key", "on");
+      endif
+      color = options(i).color;
+      if (isempty (color))
+	color = __next_line_color__ ();
+      endif
+
+      retval(i) = line (x(:,i), y, "keylabel", tkey, "color", color,
+			"linestyle", options(i).linestyle,
+			"marker", options(i).marker, properties{:});
+    endfor
+  else
+    error ("__plt2mv__: arguments must be a matrices");
+  endif
+
+endfunction
+
+function retval = __plt2ss__ (h, x, y, options, properties)
+
+  if (nargin < 3 || nargin > 5)
+    print_usage ();
+  endif
+
+  if (nargin < 4 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 5)
+    properties = {};
+  endif
+
+  if (numel (options) > 1)
+    options = options(1);
+  endif
+
+  [x_nr, x_nc] = size (x);
+  [y_nr, y_nc] = size (y);
+
+  if (x_nr == 1 && x_nr == y_nr && x_nc == 1 && x_nc == y_nc)
+    key = options.key;
+    if (! isempty (key))
+      set (h, "key", "on");
+    endif
+    color = options.color;
+    if (isempty (color))
+      color = __next_line_color__ ();
+    endif
+
+    retval = line (x, y, "keylabel", key, "color", color,
+		   "linestyle", options.linestyle,
+		   "marker", options.marker, properties{:});
+  else
+    error ("__plt2ss__: arguments must be scalars");
+  endif
+
+endfunction
+
+function retval = __plt2sv__ (h, x, y, options, properties)
+
+  if (nargin < 3 || nargin > 5)
+    print_usage ();
+  endif
+
+  if (nargin < 4 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 5)
+    properties = {};
+  endif
+
+  if (isscalar (x) && isvector (y))
+    len = numel (y);
+    if (numel (options) == 1)
+      options = repmat (options(:), len, 1);
+    endif
+    retval = zeros (len, 1);
+    for i = 1:len
+      tkey = options(i).key;
+      if (! isempty (tkey))
+	set (h, "key", "on");
+      endif
+      color = options(i).color;
+      if (isempty (color))
+	color = __next_line_color__ ();
+      endif
+
+      retval(i) = line (x, y(i), "keylabel", tkey, "color", color,
+			"linestyle", options(i).linestyle,
+			"marker", options(i).marker, properties{:});
+    endfor
+  else
+    error ("__plt2sv__: first arg must be scalar, second arg must be vector");
+  endif
+
+endfunction
+
+function retval = __plt2vm__ (h, x, y, options, properties)
+
+  if (nargin < 3 || nargin > 5)
+    print_usage ();
+  endif
+
+  if (nargin < 4 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 5)
+    properties = {};
+  endif
+
+  [x_nr, x_nc] = size (x);
+  [y_nr, y_nc] = size (y);
+
+  if (x_nr == 1)
+    x = x';
+    tmp = x_nr;
+    x_nr = x_nc;
+    x_nc = tmp;
+  endif
+
+  if (x_nr == y_nr)
+    1;
+  elseif (x_nr == y_nc)
+    y = y';
+    tmp = y_nr;
+    y_nr = y_nc;
+    y_nc = tmp;
+  else
+    error ("__plt2vm__: matrix dimensions must match");
+  endif
+
+  if (y_nc > 0)
+    if (numel (options) == 1)
+      options = repmat (options(:), y_nc, 1);
+    endif
+    retval = zeros (y_nc, 1);
+    for i = 1:y_nc
+      tkey = options(i).key;
+      if (! isempty (tkey))
+	set (h, "key", "on");
+      endif
+      color = options(i).color;
+      if (isempty (color))
+	color = __next_line_color__ ();
+      endif
+
+      retval(i) = line (x, y(:,i), "keylabel", tkey, "color", color,
+			"linestyle", options(i).linestyle,
+			"marker", options(i).marker, properties{:});
+    endfor
+  else
+    error ("__plt2vm__: arguments must be a matrices");
+  endif
+
+endfunction
+
+function retval = __plt2vs__ (h, x, y, options, properties)
+
+  if (nargin < 3 || nargin > 5)
+    print_usage ();
+  endif
+
+  if (nargin < 4 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 5)
+    properties = {};
+  endif
+
+  if (isvector (x) && isscalar (y))
+    len = numel (x);
+    if (numel (options) == 1)
+      options = repmat (options(:), len, 1);
+    endif
+    retval = zeros (len, 1);
+    for i = 1:len
+      tkey = options(i).key;
+      if (! isempty (tkey))
+	set (h, "key", "on");
+      endif
+      color = options(i).color;
+      if (isempty (color))
+	color = __next_line_color__ ();
+      endif
+
+      retval(i) = line (x(i), y, "keylabel", tkey, "color", color,
+			"linestyle", options(i).linestyle,
+			"marker", options(i).marker, properties{:});
+    endfor
+  else
+    error ("__plt2vs__: first arg must be vector, second arg must be scalar");
+  endif
+
+endfunction
+
+function retval = __plt2vv__ (h, x, y, options, properties)
+
+  if (nargin < 3 || nargin > 5)
+    print_usage ();
+  endif
+
+  if (nargin < 4 || isempty (options))
+    options = __default_plot_options__ ();
+  endif
+
+  if (nargin < 5)
+    properties = {};
+  endif
+
+  if (numel (options) > 1)
+    options = options(1);
+  endif
+
+  [x_nr, x_nc] = size (x);
+  [y_nr, y_nc] = size (y);
+
+  if (x_nr == 1)
+    x = x';
+    tmp = x_nr;
+    x_nr = x_nc;
+    x_nc = tmp;
+  endif
+
+  if (y_nr == 1)
+    y = y';
+    tmp = y_nr;
+    y_nr = y_nc;
+    y_nc = tmp;
+  endif
+
+  if (x_nr == y_nr)
+    key = options.key;
+    if (! isempty (key))
+      set (h, "key", "on");
+    endif
+    color = options.color;
+    if (isempty (color))
+      color = __next_line_color__ ();
+    endif
+
+    retval = line (x, y, "keylabel", key, "color", color,
+	      "linestyle", options.linestyle,
+	      "marker", options.marker, properties{:});
+  else
+    error ("__plt2vv__: vector lengths must match");
+  endif
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__pltopt__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,235 @@
+## Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2005,
+##               2006, 2007, 2009 John W. Eaton
+##
+## 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} {} __pltopt__ (@var{caller}, @var{opt})
+## Undocumented internal function.
+## @end deftypefn
+
+## @deftypefn {Function File} {} __pltopt__ (@var{caller}, @var{opt})
+##
+## Decode plot option strings.
+##
+## @var{opt} can currently be some combination of the following:
+##
+## @table @code
+## @item "-"
+## For solid linestyle (default).
+##
+## @item "--"
+## For dashed line style.
+##
+## @item "-."
+## For linespoints plot style.
+##
+## @item ":"
+## For dots plot style.
+##
+## @item "r"
+## Red line color.
+##
+## @item "g"
+## Green line color.
+##
+## @item "b"
+## Blue line color.
+##
+## @item "c"
+## Cyan line color.
+##
+## @item "m"
+## Magenta line color.
+##
+## @item "y"
+## Yellow line color.
+##
+## @item "k"
+## Black line color.
+##
+## @item "w"
+## White line color.
+##
+## @item ";title;"
+## Here @code{"title"} is the label for the key.
+##
+## @item "+"
+## @itemx "o"
+## @itemx "*"
+## @itemx "."
+## @itemx "x"
+## @itemx "s"
+## @itemx "d"
+## @itemx "^"
+## @itemx "v"
+## @itemx ">"
+## @itemx "<"
+## @itemx "p"
+## @itemx "h"
+## Used in combination with the points or linespoints styles, set the point
+## style.
+## @end table
+##
+## The legend may be fixed to include the name of the variable
+## plotted in some future version of Octave.
+
+## Author: jwe
+
+function [options, valid] = __pltopt__ (caller, opt, err_on_invalid)
+
+  valid = true;
+  options =  __default_plot_options__ ();
+
+  if ((nargin == 2 || nargin == 3) && (nargout == 1 || nargout == 2))
+    if (nargin == 2)
+      err_on_invalid = true;
+    endif
+    if (ischar (opt))
+      nel = rows (opt);
+    elseif (iscellstr (opt))
+      nel = numel (opt);
+    else
+      error ("__pltopt__: expecting argument to be character string or cell array of character strings");
+    endif
+    if (ischar (opt))
+      opt = cellstr (opt);
+    endif
+    for i = nel:-1:1
+      [options(i), valid] = __pltopt1__ (caller, opt{i}, err_on_invalid);
+      if (! err_on_invalid && ! valid)
+	return;
+      endif
+    endfor
+  else
+    print_usage ();
+  endif
+
+endfunction
+
+## Really decode plot option strings.
+
+## Author: Rick Niles <niles@axp745.gsfc.nasa.gov>
+## Adapted-By: jwe
+## Maintainer: jwe
+
+function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid)
+
+  options = __default_plot_options__ ();
+  valid = true;
+
+  more_opts = 1;
+
+  if (nargin != 2 && nargin != 3)
+    print_usage ();
+  endif
+
+  if (! ischar (opt))
+    return;
+  endif
+
+  have_linestyle = false;
+  have_marker = false;
+
+  ## If called by __errplot__, extract the linestyle before proceeding.
+  if (strcmp (caller,"__errplot__"))
+    if (strncmp (opt, "#~>", 3))
+      n = 3;
+    elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2))
+      n = 2;
+    elseif (strncmp (opt, "~", 1) || strncmp (opt, ">", 1) 
+	    || strncmp (opt, "#", 1))
+      n = 1;
+    endif
+      options.linestyle = opt(1:n);
+      opt(1:n) = [];
+      have_linestyle = true;
+  endif
+
+  while (! isempty (opt))
+    if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2))
+      options.linestyle = opt(1:2);
+      have_linestyle = true;
+      n = 2;
+    else
+      topt = opt(1);
+      n = 1;
+      if (topt == "-" || topt == ":")
+	have_linestyle = true;
+	options.linestyle = topt;
+      elseif (topt == "+" || topt == "o" || topt == "*"
+	      || topt == "." || topt == "x" || topt == "s"
+	      || topt == "d" || topt == "^" || topt == "v"
+	      || topt == ">" || topt == "<" || topt == "p"
+	      || topt == "h" || topt == "@")
+	have_marker = true;
+	## Backward compatibility.  Leave undocumented.
+	if (topt == "@")
+	  topt = "+";
+	endif
+	options.marker = topt;
+### Numeric color specs for backward compatibility.  Leave undocumented.
+      elseif (topt == "k" || topt == "0")
+	options.color = [0, 0, 0];
+      elseif (topt == "r" || topt == "1")
+	options.color = [1, 0, 0];
+      elseif (topt == "g" || topt == "2")
+	options.color = [0, 1, 0];
+      elseif (topt == "b" || topt == "3")
+	options.color = [0, 0, 1];
+      elseif (topt == "y")
+	options.color = [1, 1, 0];
+      elseif (topt == "m" || topt == "4")
+	options.color = [1, 0, 1];
+      elseif (topt == "c" || topt == "5")
+	options.color = [0, 1, 1];
+      elseif (topt == "w" || topt == "6")
+	options.color = [1, 1, 1];
+      elseif (isspace (topt))
+	## Do nothing.
+      elseif (topt == ";")
+	t = index (opt(2:end), ";");
+	if (t)
+	  options.key = undo_string_escapes (opt(2:t));
+	  n = t+1;
+	else
+	  if (err_on_invalid)
+            error ("%s: unfinished key label", caller);
+	  else
+	    valid = false;
+	    options = __default_plot_options__ ();
+	    return;
+	  endif
+        endif
+      else
+	if (err_on_invalid)
+	  error ("%s: unrecognized format character: `%s'", caller, topt);
+	else
+	  valid = false;
+	  options = __default_plot_options__ ();
+	  return;
+	endif
+      endif
+    endif
+    opt(1:n) = [];
+  endwhile
+
+  if (have_marker && ! have_linestyle)
+    options.linestyle = "none";
+  endif
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__quiver__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,421 @@
+## Copyright (C) 2007, 2008, 2009 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} {@var{hg} =} __quiver__ (@dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+function hg = __quiver__ (varargin)
+
+  h = varargin{1};
+  is3d = varargin{2};
+
+  autoscale = 0.9;
+  arrowsize = 0.2;
+
+  firstnonnumeric = Inf;
+  for i = 3:nargin
+    if (! isnumeric (varargin{i}))
+      firstnonnumeric = i;
+      break;
+    endif
+  endfor
+
+  ioff = 3;
+  if (nargin < (6 + is3d) || firstnonnumeric < (6 + is3d))
+    u = varargin{ioff++};
+    v = varargin{ioff++};
+    if (is3d)
+      w = varargin{ioff++}
+      [x, y, z] = meshgrid (1:size(u,2), 1:size(u,1), 1:max(size(w)));
+    else
+      [x, y] = meshgrid (1:size(u,2), 1:size(u,1));
+    endif
+    if (nargin >= ioff && isnumeric (varargin{ioff})
+	&& isscalar (varargin{ioff}))
+      autoscale = varargin{ioff++};
+    endif
+  else
+    x = varargin{ioff++};
+    y = varargin{ioff++};
+    if (is3d)
+      z = varargin{ioff++};
+    endif
+    u = varargin{ioff++};
+    v = varargin{ioff++}; 
+    if (is3d)
+      w = varargin{ioff++};
+      if (isvector (x) && isvector (y) && isvector (z)
+	  && (! isvector (u) || ! isvector (v) || ! isvector(w)))
+	[x, y, z] = meshgrid (x, y, z);
+      endif
+    else
+      if (isvector (x) && isvector (y) && (! isvector (u) || ! isvector (v)))
+	[x, y] = meshgrid (x, y);
+      endif
+    endif
+    if (nargin >= ioff && isnumeric (varargin{ioff})
+	&& isscalar (varargin{ioff}))
+      autoscale = varargin{ioff++};
+    endif
+  endif
+
+  have_filled = false;
+  have_line_spec = false;
+  args = {};
+  while (ioff <= nargin)
+    arg = varargin{ioff++};
+    if (ischar (arg) && strncmpi (arg, "filled", 6))
+      have_filled = true;
+    elseif ((ischar (arg) || iscell (arg))
+	    && ! have_line_spec)
+      [linespec, valid] = __pltopt__ ("quiver", arg, false);
+      if (valid)
+	have_line_spec = true;
+	if (strncmp (linespec.linestyle, "none", 4))
+	  linespec.linestyle = "-";
+	endif
+      else
+	args {end + 1} = arg;
+        if (ioff <= nargin)
+          args {end + 1} = varargin{ioff++};
+        endif
+      endif
+    else
+      args {end + 1} = arg;
+      if (ioff <= nargin)
+        args {end + 1} = varargin{ioff++};
+      endif
+    endif
+  endwhile
+
+  if (autoscale && numel (u) > 1)
+    ## Scale the arrows to fit in the grid
+    dx = (max(x(:)) - min(x(:))) ./ size (x, 2);
+    dy = (max(y(:)) - min(y(:))) ./ size (y, 1);
+    if (is3d)
+      ## What should this be divided by? The below seems right
+      dz = (max(z(:)) - min(z(:))) ./ max (size (z));
+      len = max (sqrt (u(:).^2 + dy(:).^2) + dz(:).^2);
+    else
+      len = max (sqrt (u(:).^2 + dy(:).^2));
+      dz = 0;
+    endif
+    if (len > 0)
+      s = 2 * autoscale / sqrt (2) * sqrt (dx.^2 + dy.^2 + dz.^2) / len; 
+      uu = s * u;
+      vv = s * v;
+      if (is3d)
+	ww = s*w;
+      endif
+    endif
+  else
+    uu = u;
+    vv = v;
+    if (is3d)
+      ww = w;
+    endif
+  endif
+
+  hstate = get (h, "nextplot");
+  unwind_protect
+    hg = hggroup ();
+    if (is3d)
+      args = __add_datasource__ ("quiver3", hg, 
+				 {"x", "y", "z", "u", "v", "w"}, args{:});
+    else
+      args = __add_datasource__ ("quiver", hg, 
+				 {"x", "y", "z", "u", "v", "w"}, args{:});
+    endif
+    hold on;
+
+    addproperty ("xdata", hg, "data", x);
+    addproperty ("ydata", hg, "data", y);
+
+    addproperty ("udata", hg, "data", u);
+    addproperty ("vdata", hg, "data", v);
+    if (is3d)
+      addproperty ("zdata", hg, "data", z);
+      addproperty ("wdata", hg, "data", w);
+    else
+      addproperty ("zdata", hg, "data", []);
+      addproperty ("wdata", hg, "data", []);
+    endif
+
+    addlistener (hg, "xdata", @update_data);
+    addlistener (hg, "ydata", @update_data);
+    addlistener (hg, "zdata", @update_data);
+    addlistener (hg, "udata", @update_data);
+    addlistener (hg, "vdata", @update_data);
+    addlistener (hg, "wdata", @update_data);
+
+    x = x(:);
+    y = y(:);
+    xend = x + uu(:);
+    yend = y + vv(:);
+    if (is3d)
+      z = z(:);
+      zend = z + ww(:);
+    endif
+
+    if (have_line_spec)
+      if (is3d)
+	h1 = plot3 ([x.'; xend.'; NaN(1, length (x))](:),
+		    [y.'; yend.'; NaN(1, length (y))](:),
+		    [z.'; zend.'; NaN(1, length (z))](:),
+		    "linestyle", linespec.linestyle, 
+		    "color", linespec.color, "parent", hg);
+      else
+	h1 = plot ([x.'; xend.'; NaN(1, length (x))](:),
+		   [y.'; yend.'; NaN(1, length (y))](:),
+		   "linestyle", linespec.linestyle, 
+		    "color", linespec.color, "parent", hg);
+      endif
+    else
+      if (is3d)
+	h1 = plot3 ([x.'; xend.'; NaN(1, length (x))](:),
+		    [y.'; yend.'; NaN(1, length (y))](:),
+		    [z.'; zend.'; NaN(1, length (z))](:),
+		    "parent", hg);
+      else
+	h1 = plot ([x.'; xend.'; NaN(1, length (x))](:),
+		   [y.'; yend.'; NaN(1, length (y))](:),
+		   "parent", hg);
+      endif
+    endif
+
+    xtmp = x + uu(:) .* (1 - arrowsize);
+    ytmp = y + vv(:) .* (1 - arrowsize);
+    xarrw1 = xtmp + (y - yend) * arrowsize / 3;
+    xarrw2 = xtmp - (y - yend) * arrowsize / 3;
+    yarrw1 = ytmp - (x - xend) * arrowsize / 3;
+    yarrw2 = ytmp + (x - xend) * arrowsize / 3;
+    if (is3d)
+      zarrw1 = zarrw2 = zend - ww(:) * arrowsize;
+    endif
+
+    if (have_line_spec)
+      if (isfield (linespec, "marker") && 
+	! strncmp (linespec.marker, "none", 4))
+	if (is3d)
+	  h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
+		      [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
+		      [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:),
+		      "linestyle", "none", "parent", hg);
+	else
+	  h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
+		     [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
+		     "linestyle", "none", "parent", hg);
+	endif
+      else
+	if (is3d)
+	  h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
+		      [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
+		      [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:),
+		      "linestyle", linespec.linestyle,
+		      "color", linespec.color, "parent", hg);
+	else
+	  h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
+		     [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
+		     "linestyle", linespec.linestyle,
+		      "color", linespec.color, "parent", hg);
+	endif
+      endif
+    elseif (is3d)
+      h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
+		  [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
+		  [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:),
+		  "parent", hg);
+    else
+      h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
+		 [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
+		 "parent", hg);
+    endif
+
+    if (! have_line_spec
+	|| (isfield (linespec, "marker")
+	    && strncmp (linespec.marker, "none", 4)))
+      if (is3d)
+	h3 = plot3 (x, y, z, "linestyle", "none", "marker", "none", 
+		    "parent", hg);
+      else
+	h3 = plot (x, y, "linestyle", "none", "marker", "none", "parent", hg);
+      endif
+    else
+      if (is3d)
+	h3 = plot3 (x, y, z, "linestyle", "none", "marker", linespec.marker,
+		    "parent", hg);
+      else
+
+	h3 = plot (x, y, "linestyle", "none", "marker", linespec.marker,
+		   "parent", hg);
+      endif
+    endif
+    if (have_filled)
+      ## FIXME gnuplot doesn't respect the markerfacecolor field
+      set (h3, "markerfacecolor", get (h1, "color")); 
+    endif
+
+    ## Set up the hggroup properties and listeners
+    if (autoscale)
+      addproperty ("autoscale", hg, "radio", "{on}|off", "on");
+      addproperty ("autoscalefactor", hg, "data", autoscale)
+    else
+      addproperty ("autoscale", hg, "radio", "{on}|off", "off");
+      addproperty ("autoscalefactor", hg, "data", 1.0)
+    endif
+    addlistener (hg, "autoscale", @update_data)
+    addlistener (hg, "autoscalefactor", @update_data)
+
+    addproperty ("maxheadsize", hg, "data", arrowsize)
+    addlistener (hg, "maxheadsize", @update_data);
+
+    addproperty ("showarrowhead", hg, "radio", "{on}|off", "on");
+    addlistener (hg, "showarrowhead", @update_props);
+
+    addproperty ("color", hg, "linecolor", get (h1, "color"));
+    addproperty ("linewidth", hg, "linelinewidth", get (h1, "linewidth"));
+    addproperty ("linestyle", hg, "linelinestyle", get (h1, "linestyle"));
+    addproperty ("marker", hg, "linemarker", get (h3, "marker"));
+    addproperty ("markerfacecolor", hg, "linemarkerfacecolor",
+		 get (h3, "markerfacecolor"));
+    addproperty ("markersize", hg, "linemarkersize", get (h3, "markersize"));
+
+    addlistener (hg, "color", @update_props);
+    addlistener (hg, "linewidth", @update_props); 
+    addlistener (hg, "linestyle", @update_props); 
+    addlistener (hg, "marker", @update_props); 
+    addlistener (hg, "markerfacecolor", @update_props); 
+    addlistener (hg, "markersize", @update_props);
+
+    if (! isempty (args))
+      set (hg, args{:});
+    endif
+  unwind_protect_cleanup
+    set (h, "nextplot", hstate);
+  end_unwind_protect
+
+endfunction
+
+function update_data (h, d)
+  x = get (h, "xdata");
+  y = get (h, "ydata");
+  z = get (h, "zdata");
+
+  u = get (h, "udata");
+  v = get (h, "vdata");
+  w = get (h, "wdata");
+
+  s = get (h, "autoscalefactor");
+  arrowsize = get (h, "maxheadsize");
+
+  kids = get (h, "children");
+
+  if (isempty (z) || isempty (w))
+    is3d = false;
+  else
+    is3d = true;
+  endif
+
+  if (strcmpi (get (h, "autoscale"), "on") && s != 0)
+    ## Scale the arrows to fit in the grid
+    dx = (max(x(:)) - min(x(:))) ./ size (x, 2);
+    dy = (max(y(:)) - min(y(:))) ./ size (y, 1);
+    if (is3d)
+      ## What should this be divided by? The below seems right
+      dz = (max(z(:)) - min(z(:))) ./ max (size (z));
+      len = max (sqrt (u(:).^2 + dy(:).^2) + dz(:).^2);
+    else
+      len = max (sqrt (u(:).^2 + dy(:).^2));
+      dz = 0;
+    endif
+    if (len > 0)
+      s = 2 * s / sqrt (2) * sqrt (dx.^2 + dy.^2 + dz.^2) / len; 
+      u = s * u;
+      v = s * v;
+      if (is3d)
+	w = s*w;
+      endif
+    endif
+  endif
+
+  x = x(:);
+  y = y(:);
+  xend = x + u(:);
+  yend = y + v(:);
+  if (is3d)
+    z = z(:);
+    zend = z + w(:);
+  endif
+
+  set (kids (3), "xdata", [x.'; xend.'; NaN(1, length (x))](:));
+  set (kids (3), "ydata", [y.'; yend.'; NaN(1, length (y))](:));
+  if (is3d)
+    set (kids (3), "zdata", [z.'; zend.'; NaN(1, length (z))](:));
+  endif
+
+  xtmp = x + u(:) .* (1 - arrowsize);
+  ytmp = y + v(:) .* (1 - arrowsize);
+  xarrw1 = xtmp + (y - yend) * arrowsize / 3;
+  xarrw2 = xtmp - (y - yend) * arrowsize / 3;
+  yarrw1 = ytmp - (x - xend) * arrowsize / 3;
+  yarrw2 = ytmp + (x - xend) * arrowsize / 3;
+  if (is3d)
+    zarrw1 = zarrw2 = zend - w(:) * arrowsize;
+  endif
+
+  set (kids (2), "xdata", [x.'; xend.'; NaN(1, length (x))](:));
+  set (kids (2), "ydata", [y.'; yend.'; NaN(1, length (y))](:));
+  if (is3d)
+    set (kids (2), "zdata", [z.'; zend.'; NaN(1, length (z))](:));
+  endif
+
+  set (kids (2), "xdata", [xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:));
+  set (kids (2), "ydata", [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:));
+  if (is3d)
+    set (kids (2), "zdata", [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:));
+  endif
+
+  set (kids (1), "xdata", x);
+  set (kids (1), "ydata", y);
+  if (is3d)
+    set (kids (1), "zdata", z);
+  endif
+
+endfunction
+
+function update_props (h, d)
+  kids = get (h, "children");
+
+  set (kids(3), "color", get (h, "color"), 
+       "linewidth", get (h, "linewidth"),
+       "linestyle", get (h, "linestyle"));
+  set (kids(2), "color", get (h, "color"), 
+       "linewidth", get (h, "linewidth"),
+       "linestyle", get (h, "linestyle"));
+  if (strcmpi (get (h, "showarrowhead"), "on"))
+    set (kids (2), "visible", "on");
+  else
+    set (kids (2), "visible", "off");
+  endif
+  set (kids(1), "color", get (h, "color"), 
+       "marker", get (h, "marker"),
+       "markerfacecolor", get (h, "markerfacecolor"),
+       "markersize", get (h, "markersize"));
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__scatter__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,246 @@
+## Copyright (C) 2007, 2008, 2009 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} {@var{hg} =} __scatter__ (@dots{})
+## Undocumented internal function.
+## @end deftypefn
+
+function hg = __scatter__ (varargin)
+
+  h = varargin{1};
+  nd = varargin{2};
+  fcn = varargin{3};
+  x = varargin{4}(:);
+  y = varargin{5}(:);
+  istart = 6;
+
+  if (nd == 3)
+    z = varargin{6}(:);
+    idx = isnan(x) | isnan (y) | isnan (z);
+    x (idx) = [];
+    y (idx) = [];
+    z (idx) = [];
+    istart = 7;
+  else
+    idx = isnan(x) | isnan (y);
+    x (idx) = [];
+    y (idx) = [];
+    z = zeros (length (x), 0);
+  endif
+
+  firstnonnumeric = Inf;
+  for i = istart:nargin
+    if (! isnumeric (varargin{i}))
+      firstnonnumeric = i;
+      break;
+    endif
+  endfor
+
+  if (istart < nargin && firstnonnumeric > istart)
+    s = varargin{istart};
+    if (isempty (s))
+      s = 6;
+    endif
+  else
+    s = 6;
+  endif
+  if (numel (s) == 1)
+    ss = s;
+    s = repmat (s, numel(x), 1);
+  endif
+
+  if (istart < nargin && firstnonnumeric > istart + 1)
+    c = varargin{istart + 1};
+    if (isvector (c))
+      if (columns (c) == 3)
+	cc = c;
+	c = repmat (c, numel(x), 1);
+      else
+	c = c(:);
+      endif
+    elseif (isempty (c))
+      cc = __next_line_color__();
+      c = repmat (cc, numel(x), 1);
+    endif
+  elseif (firstnonnumeric == istart + 1 && ischar (varargin{istart + 1}))
+    c = varargin{istart + 1};
+    firstnonnumeric++;
+  else
+    cc = __next_line_color__();
+    c = repmat (cc, numel(x), 1);
+  endif
+
+  newargs = {};
+  filled = false;
+  have_marker = false;
+  marker = "o";
+  iarg = firstnonnumeric;
+  while (iarg <= nargin)
+    arg = varargin{iarg++};
+    if (ischar (arg) && strncmpi (arg, "filled", 6))
+      filled = true;
+    elseif ((ischar (arg) || iscell (arg)) && ! have_marker)
+      [linespec, valid] = __pltopt__ (fcn, arg, false);
+      if (valid)
+	have_marker = true;
+	marker = linespec.marker;
+	if (strncmp (marker, "none", 4))
+	  marker = "o";
+	endif
+      else
+	error ("%s: invalid linespec", fcn);
+      endif
+    else
+      newargs{end+1} = arg;
+      if (iarg <= nargin)
+	newargs{end+1} = varagin{iarg++};
+      endif
+    endif
+  endwhile
+
+  hg = hggroup ();
+  newargs = __add_datasource__ (fcn, hg, {"x", "y", "z", "c", "size"}, 
+			     newargs{:});
+
+  addproperty ("xdata", hg, "data", x);
+  addproperty ("ydata", hg, "data", y);
+  addproperty ("zdata", hg, "data", z);
+  if (exist ("cc", "var"))
+    addproperty ("cdata", hg, "data", cc);
+  else
+    addproperty ("cdata", hg, "data", c);
+  endif
+  if (exist ("ss", "var"))
+    addproperty ("sizedata", hg, "data", ss);
+  else
+    addproperty ("sizedata", hg, "data", s);
+  endif
+  addlistener (hg, "xdata", @update_data);
+  addlistener (hg, "ydata", @update_data);
+  addlistener (hg, "zdata", @update_data);
+  addlistener (hg, "cdata", @update_data);
+  addlistener (hg, "sizedata", @update_data);
+
+  if (ischar (c))
+    for i = 1 : numel (x)
+      h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:),
+			"faces", 1, "vertices", [x(i), y(i), z(i,:)], 
+			"facecolor", "none", "edgecolor", c, "marker", marker, 
+			"markersize", s(i), "linestyle", "none");
+      if (filled)
+	set(h, "markerfacecolor", c); 
+      endif
+    endfor
+  else
+    for i = 1 : numel (x)
+      h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:),
+			"faces", 1, "vertices", [x(i), y(i), z(i,:)], 
+			"facecolor", "none", "edgecolor", "flat", 
+			"cdata", reshape(c(i,:),[1,size(c)(2:end)]), 
+			"marker", marker, "markersize", s(i), 
+			"linestyle", "none");
+      if (filled)
+	set(h, "markerfacecolor", "flat"); 
+      endif
+    endfor
+    ax = get (hg, "parent");
+    clim = get (ax, "clim");
+    if (min(c(:)) < clim(1))
+      clim(1) = min(c(:));
+      set (ax, "clim", clim);
+    endif
+    if (max(c(:)) > clim(2))
+      set (ax, "clim", [clim(1), max(c(:))]);
+    endif
+  endif
+
+  addproperty ("linewidth", hg, "patchlinewidth", 0.5);
+  addproperty ("marker", hg, "patchmarker", marker);
+  if (numel (x) > 0)
+    addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", "none");
+    addproperty ("markeredgecolor", hg, "patchmarkeredgecolor", "none");
+  else
+    addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", 
+		 get (h, "markerfacecolor"));
+    addproperty ("markeredgecolor", hg, "patchmarkeredgecolor",
+		 get (h, "edgecolor"));
+  endif
+  addlistener (hg, "linewidth", @update_props); 
+  addlistener (hg, "marker", @update_props); 
+  addlistener (hg, "markerfacecolor", @update_props); 
+  addlistener (hg, "markeredgecolor", @update_props);
+
+  if (! isempty (newargs))
+    set (hg, newargs{:})
+  endif
+
+endfunction
+
+function update_props (h, d)
+  lw = get (h, "linewidth");
+  m = get (h, "marker");
+  fc = get (h, "markerfacecolor");
+  ec = get (h, "markeredgecolor");
+  kids = get (h, "children");
+
+  for i = 1 : numel (kids)
+    set (kids (i), "linewidth", lw, "marker", m, "markerfacecolor", fc, 
+	 "edgecolor", ec)
+  endfor
+endfunction
+
+function update_data (h, d)
+  x1 = get (h, "xdata");
+  y1 = get (h, "ydata");
+  z1 = get (h, "zdata");
+  c1 = get (h, "cdata");
+  if (!ischar (c1) && rows (c1) == 1)
+    c1 = repmat (c1, numel (x1), 1);
+  endif
+  size1 = get (h, "sizedata");
+  if (numel (size1) == 1)
+    size1 = repmat (size1, numel (x1), 1);
+  endif
+  hlist = get (h, "children");
+  if (ischar (c1))
+    if (isempty (z1))
+      for i = 1 : length (hlist)
+	set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", c1,
+	     "markersize", size1(i));
+      endfor
+    else
+      for i = 1 : length (hlist)
+	set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", c1,
+	     "markersize", size1(i));
+      endfor
+    endif
+  else
+    if (isempty (z1))
+      for i = 1 : length (hlist)
+	set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", 
+	     reshape(c1(i,:),[1, size(c1)(2:end)]), "markersize", size1(i));
+      endfor
+    else
+      for i = 1 : length (hlist)
+	set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", 
+	     reshape(c1(i,:),[1, size(c1)(2:end)]), "markersize", size1(i));
+      endfor
+    endif
+  endif
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/private/__stem__.m	Tue Dec 01 15:59:43 2009 -0500
@@ -0,0 +1,553 @@
+## Copyright (C) 2006, 2007, 2008, 2009 Michel D. Schmid
+##
+## 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} {@var{h} =} __stem__ (@var{have_z}, @var{varargin})
+## Undocumented internal function.
+## @end deftypefn
+
+## Author: Michel D. Schmid <michaelschmid@users.sourceforge.net>
+## Adapted-by: jwe
+
+function h = __stem__ (have_z, varargin)
+
+  if (have_z)
+    caller = "stem3";
+  else
+    caller = "stem";
+  endif
+
+  [ax, varargin, nargin] = __plt_get_axis_arg__ (caller, varargin{:});
+
+  [x, y, z, dofill, llc, ls, mmc, ms, varargin] = ...
+      check_stem_arg (have_z, varargin{:});
+
+  oldax = gca ();
+  unwind_protect
+    axes (ax);
+    hold_state = get (ax, "nextplot");
+    newplot ();
+    h = [];
+
+    nx = rows (x);
+    for i = 1: columns (x)
+      if (have_z)
+	xt = x(:)';
+	xt = [xt; xt; NaN(1, nx)](:);
+	yt = y(:)';
+	yt = [yt; yt; NaN(1, nx)](:);
+	zt = z(:)';
+	zt = [zeros(1, nx); zt; NaN(1, nx)](:);
+      else
+	xt = x(:, i)';
+	xt = [xt; xt; NaN(1, nx)](:);
+	yt = y(:, i)';
+	yt = [zeros(1, nx); yt; NaN(1, nx)](:);
+      endif
+
+      hg  = hggroup ();
+      h = [h; hg];
+      args = __add_datasource__ (caller, hg, {"x", "y", "z"}, varargin{:});
+      
+      if (i == 1)
+	set (ax, "nextplot", "add");
+      endif
+
+      if (isempty (llc))
+	lc = __next_line_color__ ();
+      else
+	lc = llc;
+      endif
+
+      if (isempty (mmc))
+	mc = lc;
+      else
+	mc = mmc;
+      endif
+
+      if (dofill)
+	fc = mc;
+      else
+	fc = "none";
+      endif
+
+      if (have_z)
+	h_stems = plot3 (xt, yt, zt, "color", lc, "linestyle", ls, 
+			 "parent", hg, x, y, z, "color", mc,
+			 "marker",  ms, "linestyle", "none",
+			 "markerfacecolor", fc, "parent", hg);
+
+	h_baseline = [];
+      else
+	h_stems = plot (xt, yt, "color", lc, "linestyle", ls,
+			"parent", hg, x(:,i), y(:, i), "color", mc, "marker",
+			ms, "linestyle", "none", "markerfacecolor",
+			fc, "parent", hg); 
+
+	if (i == 1)
+	  x_axis_range = get (ax, "xlim");
+	  h_baseline = line (x_axis_range, [0, 0], "color", [0, 0, 0]);
+	  set (h_baseline, "handlevisibility", "off");
+	  set (h_baseline, "xliminclude", "off");
+	  addlistener (ax, "xlim", @update_xlim);
+	  addlistener (h_baseline, "ydata", @update_baseline);
+	  addlistener (h_baseline, "visible", @update_baseline);
+	endif
+      endif
+
+      ## Setup the hggroup and listeners.
+      addproperty ("showbaseline", hg, "radio", "{on}|off");
+      addproperty ("basevalue", hg, "data", 0);
+      addproperty ("baseline", hg, "data", h_baseline);
+
+      if (!have_z)
+	addlistener (hg, "showbaseline", @show_baseline);
+	addlistener (hg, "basevalue", @move_baseline); 
+      endif
+
+      addproperty ("color", hg, "linecolor", lc);
+      addproperty ("linewidth", hg, "linelinewidth", 0.5);
+      addproperty ("linestyle", hg, "linelinestyle", ls);
+      addproperty ("marker", hg, "linemarker", ms);
+      addproperty ("markerfacecolor", hg, "linemarkerfacecolor", fc);
+      addproperty ("markersize", hg, "linemarkersize", 6);
+
+      addlistener (hg, "color", @update_props);
+      addlistener (hg, "linewidth", @update_props); 
+      addlistener (hg, "linestyle", @update_props); 
+      addlistener (hg, "marker", @update_props); 
+      addlistener (hg, "markerfacecolor", @update_props); 
+      addlistener (hg, "markersize", @update_props);
+
+      addproperty ("xdata", hg, "data", x(:, i));
+      addproperty ("ydata", hg, "data", y(:, i));
+      if (have_z)
+	addproperty ("zdata", hg, "data", z(:, i));
+      else
+	addproperty ("zdata", hg, "data", []);
+      endif
+
+      addlistener (hg, "xdata", @update_data);
+      addlistener (hg, "ydata", @update_data);
+      addlistener (hg, "zdata", @update_data);
+
+      if (! isempty (args))
+	set (hg, args{:});
+      endif
+      if (i == 1 && !isempty(h_baseline))
+	set (h_baseline, "parent", get (hg, "parent"));
+      endif
+    endfor
+
+  unwind_protect_cleanup
+    set (ax, "nextplot", hold_state);
+    axes (oldax);
+  end_unwind_protect
+endfunction
+
+function [x, y, z, dofill, lc, ls, mc, ms, newargs] = check_stem_arg (have_z, varargin)
+
+  ## FIXME -- there seems to be a lot of duplicated code in this
+  ## function.  It seems like it should be possible to simplify things
+  ## by combining some of the nearly identical code sections into
+  ## additional subfunctions.
+
+  if (have_z)
+    caller = "stem3";
+  else
+    caller = "stem";
+  endif
+
+  ## Remove prop/val pairs from data to consider.
+  i = 2;
+  newargs = {};
+  while (i < length (varargin))
+    if (ischar (varargin{i}) && !(strcmpi ("fill", varargin{i})
+				  || strcmpi ("filled", varargin{i})))
+      newargs{end + 1} = varargin{i};
+      newargs{end + 1} = varargin{i + 1};
+      nargin = nargin - 2;
+      varargin(i:i+1) = [];
+    else
+      i++;
+    endif
+  endwhile
+
+  ## set specifiers to default values.
+  [lc, ls, mc, ms] = set_default_values ();
+  dofill = 0;
+  fill_2 = 0;
+  linespec_2 = 0;
+  z = [];
+
+  ## Check input arguments.
+  if (nargin == 2)
+    if (have_z)
+      z = varargin{1};
+      x = 1:rows (z);
+      y = 1:columns (z);
+    else
+      y = varargin{1};
+      if (isvector (y))
+	x = 1:length (y);
+      elseif (ismatrix (y))
+	x = 1:rows (y);
+      else 
+	error ("stem: Y must be a matrix");
+      endif # in each case, x & y will be defined
+    endif
+  elseif (nargin == 3)
+    ## Several possibilities
+    ##
+    ## 1. the real y data
+    ## 2. 'filled'
+    ## 3. line spec
+    if (ischar (varargin{2}))
+      ## Only 2. or 3. possible.
+      if (strcmpi ("fill", varargin{2}) || strcmpi ("filled", varargin{2}))
+	dofill = 1;
+      else
+	## Parse the linespec.
+	[lc, ls, mc, ms] = stem_line_spec (caller, varargin{2});
+      endif
+      if (have_z)
+	z = varargin{1};
+	x = 1:rows (z);
+	y = 1:columns (z);
+      else
+	y = varargin{1};
+	if (isvector (y))
+	  x = 1:length (y);
+	elseif (ismatrix (y))
+	  x = 1:rows (y);
+	else
+	  error ("stem: Y must be a matrix");
+	endif # in each case, x & y will be defined
+      endif
+    else
+      if (have_z)
+	error ("stem3: must define X, Y and Z");
+      else
+	## Must be the real y data.
+	x = varargin{1};
+	y = varargin{2};
+	if (! (ismatrix (x) && ismatrix (y)))
+	  error ("stem: X and Y must be matrices");
+	endif
+      endif
+    endif
+  elseif (nargin == 4)
+    ## Again, several possibilities:
+    ##
+    ## arg2 1. real y
+    ## arg2 2. 'filled' or linespec
+    ## arg3 1. real z
+    ## arg3 2. 'filled' or linespec
+    if (ischar (varargin{2}))
+      ## Only arg2 2. / arg3 1. & arg3 3. are possible.
+      if (strcmpi ("fill", varargin{2}) || strcmpi ("filled", varargin{2}))
+	dofill = 1;
+	fill_2 = 1; # Be sure, no second "fill" is in the arguments.
+      else
+	## Must be a linespec.
+	[lc, ls, mc, ms] = stem_line_spec (caller, varargin{2});
+	linespec_2 = 1;
+      endif
+      if (have_z)
+	z = varargin{1};
+	x = 1:rows (z);
+	y = 1:columns (z);
+      else
+	y = varargin{1};
+	if (isvector (y))
+	  x = 1:length (y);
+	elseif (ismatrix (y))
+	  x = 1:rows (y);
+	else
+	  error ("stem: Y must be a matrix");
+	endif # in each case, x & y will be defined
+      endif
+    else
+      if (have_z)
+	x = varargin{1};
+	y = varargin{2};
+	z = varargin{3};
+	if (! (ismatrix (x) && ismatrix (y) && ismatrix (z)))
+	  error ("stem3: X, Y and Z must be matrices");
+	endif
+      else
+	## must be the real y data.
+	x = varargin{1};
+	y = varargin{2};
+	if (! (ismatrix (x) && ismatrix (y)))
+	  error ("stem: X and Y must be matrices");
+	endif
+      endif
+    endif # if ischar(varargin{2})
+    if (! have_z)
+      ## varargin{3} must be char.
+      ## Check for "fill.
+      if ((strcmpi (varargin{3}, "fill") || strcmpi (varargin{3}, "filled"))
+	  && fill_2)
+	error ("stem: duplicate fill argument");
+      elseif (strcmpi ("fill", varargin{3}) && linespec_2)
+	## Must be "fill".
+	dofill = 1;
+	fill_2 = 1;
+      elseif ((strcmpi (varargin{3}, "fill") || strcmpi (varargin{3}, "filled"))
+	  && !linespec_2)
+	## Must be "fill".
+	dofill = 1;
+	fill_2 = 1;
+      elseif (! linespec_2)
+	## Must be linespec.
+	[lc, ls, mc, ms] = stem_line_spec (caller, varargin{3});
+	linespec_2 = 1;
+      endif
+    endif
+  elseif (nargin == 5)
+    if (have_z)
+      x = varargin{1};
+      y = varargin{2};
+      z = varargin{3};
+      if (! (ismatrix (x) && ismatrix (y) && ismatrix (z)))
+	error ("stem3: X, Y and Z must be matrices");
+      endif
+    else
+      x = varargin{1};
+      y = varargin{2};
+      if (! (ismatrix (x) && ismatrix (y)))
+	error ("stem: X and Y must be matrices");
+      endif
+    endif
+
+    if (! have_z)
+      if (strcmpi (varargin{3}, "fill") || strcmpi (varargin{3}, "filled"))
+	dofill = 1;
+	fill_2 = 1; # Be sure, no second "fill" is in the arguments.
+      else
+	## Must be a linespec.
+	[lc, ls, mc, ms] = stem_line_spec (caller, varargin{3});
+	linespec_2 = 1;
+      endif
+    endif
+
+    ## Check for "fill".
+    if ((strcmpi (varargin{4}, "fill") || strcmpi (varargin{4}, "filled"))
+	&& fill_2)
+      error ("%s: duplicate fill argument", caller);
+    elseif ((strcmpi (varargin{4}, "fill") || strcmpi (varargin{4}, "filled"))
+	&& linespec_2)
+      ## Must be "fill".
+      dofill = 1;
+      fill_2 = 1;
+    elseif (!strcmpi (varargin{4}, "fill") && !strcmpi (varargin{4}, "filled")
+	&& !linespec_2)
+      ## Must be linespec.
+      [lc, ls, mc, ms] = stem_line_spec (caller, varargin{4});
+      linespec_2 = 1;
+    endif
+  elseif (nargin == 6 && have_z)
+    x = varargin{1};
+    y = varargin{2};
+    z = varargin{3};
+    if (! (ismatrix (x) && ismatrix (y) && ismatrix (z)))
+      error ("stem3: X, Y and Z must be matrices");
+    endif
+
+    if (strcmpi (varargin{4}, "fill") || strcmpi (varargin{4}, "filled"))
+      dofill = 1;
+      fill_2 = 1; # be sure, no second "fill" is in the arguments
+    else
+      ## Must be a linespec.
+      [lc, ls, mc, ms] = stem_line_spec (caller, varargin{4});
+      linespec_2 = 1;
+    endif
+
+    ## check for "fill" ..
+    if ((strcmpi (varargin{5}, "fill") || strcmpi (varargin{5}, "filled"))
+	&& fill_2)
+      error ("stem3: duplicate fill argument");
+    elseif ((strcmpi (varargin{5}, "fill") || strcmpi (varargin{5}, "filled"))
+	&& linespec_2)
+      ## Must be "fill".
+      dofill = 1;
+      fill_2 = 1;
+    elseif (!strcmpi (varargin{5}, "fill") && !strcmpi (varargin{5}, "filled")
+	    && !linespec_2)
+      ## Must be linespec.
+      [lc, ls, mc, ms] = stem_line_spec (caller, varargin{5});
+      linespec_2 = 1;
+    endif
+  else
+    error ("%s: incorrect number of arguments", caller);
+  endif
+
+  ## Check sizes of x, y and z.
+  if (have_z)
+    if (!size_equal (x, y, z))
+      error ("stem3: inconsistent size of x, y and z");
+    else
+      x = x(:);
+      y = y(:);
+      z = z(:);
+    endif
+  else
+    if (isvector (x))
+      x = x(:);
+      if (isvector (y))
+	if (length (x) != length (y))
+	  error ("stem: inconsistent size of x and y");
+	else
+	  y = y(:);
+	endif
+      else
+	if (length (x) == rows (y))
+	  x = repmat (x(:), 1, columns (y));
+	else
+	  error ("stem: inconsistent size of x and y");
+	endif
+      endif
+    elseif (!size_equal (x, y))
+      error ("stem: inconsistent size of x and y");
+    endif
+  endif
+
+endfunction
+
+function [lc, ls, mc, ms] = stem_line_spec (caller, str)
+  if (! ischar (str))
+    error ("%s: expecting argument to be \"fill\" or a string of specifiers",
+	   caller);
+  endif
+  [lc, ls, mc, ms] = set_default_values ();
+  ## Parse the line specifier string.
+  cur_props = __pltopt__ ("stem", str, false);
+  for i = 1:length(cur_props)
+    if (isfield (cur_props(i), "color") && ! isempty (cur_props(i).color)); # means line color
+      mc = lc = cur_props(i).color;
+    elseif (isfield (cur_props(i), "linestyle"))
+      ls = cur_props(i).linestyle;
+    elseif (isfield (cur_props(i), "marker") && ! strcmpi (cur_props(i).marker, "none"))
+      ms = cur_props(i).marker;
+    endif
+  endfor
+endfunction
+
+function [lc, ls, mc, ms] = set_default_values ()
+  ## set default values
+  mc = [];
+  lc = [];
+  ls = "-";
+  ms = "o";
+endfunction
+
+function update_xlim (h, d)
+  kids = get (h, "children");
+  xlim = get (h, "xlim");
+
+  for i = 1 : length (kids)
+    obj = get (kids (i));
+    if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline"))
+      if (any (get (obj.baseline, "xdata") != xlim))
+	set (obj.baseline, "xdata", xlim);
+      endif
+    endif
+  endfor
+endfunction
+
+function update_baseline (h, d)
+  visible = get (h, "visible");
+  ydata = get (h, "ydata")(1);
+
+  kids = get (get (h, "parent"), "children");
+  for i = 1 : length (kids)
+    obj = get (kids (i));
+    if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") 
+	&& obj.baseline == h)
+      ## Only alter if changed to avoid recursion of the listener functions
+      if (! strcmpi (get (kids(i), "showbaseline"), visible))
+	set (kids (i), "showbaseline", visible);
+      endif
+      if (! strcmpi (get (kids(i), "basevalue"), visible))
+	set (kids (i), "basevalue", ydata);
+      endif
+    endif
+  endfor
+endfunction
+
+function show_baseline (h, d)
+  set (get (h, "baseline"), "visible", get (h, "showbaseline"));
+endfunction
+
+function move_baseline (h, d)
+  b0 = get (h, "basevalue");
+  bl = get (h, "baseline");
+
+  if (get (bl, "ydata") != [b0, b0])
+    set (bl, "ydata", [b0, b0]);
+  endif
+
+  kids = get (h, "children");
+  yt = get(h, "ydata")(:)';
+  ny = length (yt);
+  yt = [b0 * ones(1, ny); yt; NaN(1, ny)](:);
+  set (kids(2), "ydata", yt);
+endfunction
+
+function update_props (h, d)
+  kids = get (h, "children");
+  set (kids(2), "color", get (h, "color"), 
+       "linewidth", get (h, "linewidth"),
+       "linestyle", get (h, "linestyle"));
+  set (kids(1), "color", get (h, "color"), 
+       "marker", get (h, "marker"),
+       "markerfacecolor", get (h, "markerfacecolor"),
+       "markersize", get (h, "markersize"));
+endfunction
+
+function update_data (h, d)
+  x = get (h, "xdata");
+  y = get (h, "ydata");
+  z = get (h, "zdata");
+
+  if (!isempty (z) && size_equal (x, y, z))
+    error ("stem3: inconsistent size of x, y and z");
+  elseif (numel(x) != numel (y))
+    error ("stem: inconsistent size of x and y");
+  else
+    bl = get (h, "basevalue");
+    nx = numel (x);
+    x = x(:)';
+    xt = [x; x; NaN(1, nx)](:);
+    if (! isempty (z))
+      y = y(:)';
+      yt = [y; y; NaN(1, nx)](:);
+      z = z(:)';
+      zt = [bl * ones(1, nx); z; NaN(1, nx)](:);
+    else
+      y = y(:)';
+      yt = [bl * ones(1, nx); y; NaN(1, nx)](:);
+      zt = [];
+    endif
+
+    kids = get (h, "children");
+    set (kids(2), "xdata", xt, "ydata", yt, "zdata", zt)
+    set (kids(1), "xdata", x, "ydata", y, "zdata", z)
+  endif
+endfunction