# HG changeset patch # User John W. Eaton # Date 1259701183 18000 # Node ID 1aeb39118764056f7817a9592375c3bb72b27a80 # Parent 5a4f8d52bb0e0824459209713d0887d1884bda94 convert some plot functions to subfunctions or make some them private diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,40 @@ +2009-12-01 John W. Eaton + + * 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 * mkdoc: Handle classes in function names. diff --git a/scripts/plot/__area__.m b/scripts/plot/__area__.m deleted file mode 100644 --- a/scripts/plot/__area__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__bars__.m b/scripts/plot/__bars__.m deleted file mode 100644 --- a/scripts/plot/__bars__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plr1__.m b/scripts/plot/__plr1__.m deleted file mode 100644 --- a/scripts/plot/__plr1__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plr2__.m b/scripts/plot/__plr2__.m deleted file mode 100644 --- a/scripts/plot/__plr2__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt1__.m b/scripts/plot/__plt1__.m deleted file mode 100644 --- a/scripts/plot/__plt1__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt2__.m b/scripts/plot/__plt2__.m deleted file mode 100644 --- a/scripts/plot/__plt2__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt2mm__.m b/scripts/plot/__plt2mm__.m deleted file mode 100644 --- a/scripts/plot/__plt2mm__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt2mv__.m b/scripts/plot/__plt2mv__.m deleted file mode 100644 --- a/scripts/plot/__plt2mv__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt2ss__.m b/scripts/plot/__plt2ss__.m deleted file mode 100644 --- a/scripts/plot/__plt2ss__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt2sv__.m b/scripts/plot/__plt2sv__.m deleted file mode 100644 --- a/scripts/plot/__plt2sv__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt2vm__.m b/scripts/plot/__plt2vm__.m deleted file mode 100644 --- a/scripts/plot/__plt2vm__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt2vs__.m b/scripts/plot/__plt2vs__.m deleted file mode 100644 --- a/scripts/plot/__plt2vs__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__plt2vv__.m b/scripts/plot/__plt2vv__.m deleted file mode 100644 --- a/scripts/plot/__plt2vv__.m +++ /dev/null @@ -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 -## . - -## -*- 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 diff --git a/scripts/plot/__pltopt1__.m b/scripts/plot/__pltopt1__.m deleted file mode 100644 --- a/scripts/plot/__pltopt1__.m +++ /dev/null @@ -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 -## . - -## -*- 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 -## 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 diff --git a/scripts/plot/area.m b/scripts/plot/area.m --- a/scripts/plot/area.m +++ b/scripts/plot/area.m @@ -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 diff --git a/scripts/plot/module.mk b/scripts/plot/module.mk --- a/scripts/plot/module.mk +++ b/scripts/plot/module.mk @@ -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) diff --git a/scripts/plot/polar.m b/scripts/plot/polar.m --- a/scripts/plot/polar.m +++ b/scripts/plot/polar.m @@ -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 diff --git a/scripts/plot/__actual_axis_position__.m b/scripts/plot/private/__actual_axis_position__.m rename from scripts/plot/__actual_axis_position__.m rename to scripts/plot/private/__actual_axis_position__.m diff --git a/scripts/plot/__axes_limits__.m b/scripts/plot/private/__axes_limits__.m rename from scripts/plot/__axes_limits__.m rename to scripts/plot/private/__axes_limits__.m diff --git a/scripts/plot/__axis_label__.m b/scripts/plot/private/__axis_label__.m rename from scripts/plot/__axis_label__.m rename to scripts/plot/private/__axis_label__.m diff --git a/scripts/plot/__bar__.m b/scripts/plot/private/__bar__.m rename from scripts/plot/__bar__.m rename to scripts/plot/private/__bar__.m --- a/scripts/plot/__bar__.m +++ b/scripts/plot/private/__bar__.m @@ -152,8 +152,8 @@ axes (h); newplot (); - tmp = __bars__ (h, vertical, x, y, xb, yb, width, group, - have_line_spec, bv, newargs{:}); + tmp = bars (h, vertical, x, y, xb, yb, width, group, + have_line_spec, bv, newargs{:}); if (nargout == 1) varargout{1} = tmp; endif @@ -171,3 +171,253 @@ 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 diff --git a/scripts/plot/__clabel__.m b/scripts/plot/private/__clabel__.m rename from scripts/plot/__clabel__.m rename to scripts/plot/private/__clabel__.m diff --git a/scripts/plot/__contour__.m b/scripts/plot/private/__contour__.m rename from scripts/plot/__contour__.m rename to scripts/plot/private/__contour__.m diff --git a/scripts/plot/__default_plot_options__.m b/scripts/plot/private/__default_plot_options__.m rename from scripts/plot/__default_plot_options__.m rename to scripts/plot/private/__default_plot_options__.m diff --git a/scripts/plot/__errcomm__.m b/scripts/plot/private/__errcomm__.m rename from scripts/plot/__errcomm__.m rename to scripts/plot/private/__errcomm__.m diff --git a/scripts/plot/__errplot__.m b/scripts/plot/private/__errplot__.m rename from scripts/plot/__errplot__.m rename to scripts/plot/private/__errplot__.m diff --git a/scripts/plot/__ezplot__.m b/scripts/plot/private/__ezplot__.m rename from scripts/plot/__ezplot__.m rename to scripts/plot/private/__ezplot__.m diff --git a/scripts/plot/__interp_cube__.m b/scripts/plot/private/__interp_cube__.m rename from scripts/plot/__interp_cube__.m rename to scripts/plot/private/__interp_cube__.m diff --git a/scripts/plot/__line__.m b/scripts/plot/private/__line__.m rename from scripts/plot/__line__.m rename to scripts/plot/private/__line__.m diff --git a/scripts/plot/__patch__.m b/scripts/plot/private/__patch__.m rename from scripts/plot/__patch__.m rename to scripts/plot/private/__patch__.m diff --git a/scripts/plot/__plt__.m b/scripts/plot/private/__plt__.m rename from scripts/plot/__plt__.m rename to scripts/plot/private/__plt__.m --- a/scripts/plot/__plt__.m +++ b/scripts/plot/private/__plt__.m @@ -118,3 +118,442 @@ 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 diff --git a/scripts/plot/__pltopt__.m b/scripts/plot/private/__pltopt__.m rename from scripts/plot/__pltopt__.m rename to scripts/plot/private/__pltopt__.m --- a/scripts/plot/__pltopt__.m +++ b/scripts/plot/private/__pltopt__.m @@ -120,3 +120,116 @@ endif endfunction + +## Really decode plot option strings. + +## Author: Rick Niles +## 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 diff --git a/scripts/plot/__quiver__.m b/scripts/plot/private/__quiver__.m rename from scripts/plot/__quiver__.m rename to scripts/plot/private/__quiver__.m diff --git a/scripts/plot/__scatter__.m b/scripts/plot/private/__scatter__.m rename from scripts/plot/__scatter__.m rename to scripts/plot/private/__scatter__.m diff --git a/scripts/plot/__stem__.m b/scripts/plot/private/__stem__.m rename from scripts/plot/__stem__.m rename to scripts/plot/private/__stem__.m