Mercurial > hg > octave-terminal
changeset 6264:cc2bee854d23
[project @ 2007-02-01 10:00:05 by jwe]
author | jwe |
---|---|
date | Thu, 01 Feb 2007 10:00:05 +0000 |
parents | d60127449a29 |
children | 598c2be12ab9 |
files | scripts/ChangeLog scripts/plot/Makefile.in scripts/plot/__default_plot_options__.m scripts/plot/__next_line_color__.m scripts/plot/__plt1__.m scripts/plot/__plt2__.m scripts/plot/__plt2mm__.m scripts/plot/__plt2mv__.m scripts/plot/__plt2ss__.m scripts/plot/__plt2vm__.m scripts/plot/__plt2vv__.m scripts/plot/__plt3__.m scripts/plot/__plt__.m scripts/plot/__pltopt1__.m scripts/plot/__pltopt__.m scripts/plot/__uiobject_draw_axes__.m scripts/plot/newplot.m scripts/plot/plot3.m |
diffstat | 18 files changed, 271 insertions(+), 435 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,23 @@ +2007-02-01 John W. Eaton <jwe@octave.org> + + * plot/__plt1__.m, plot/__plt2__.m, plot/__plt2mm__.m, + plot/__plt2mv__.m, plot/__plt2ss__.m, plot/__plt2vm__.m, + plot/__plt2vv__.m, plot/__plt__.m, plot/__pltopt1__.m, + plot/__pltopt__.m, plot/plot3.m: Set and use options struct + instead of of key and fmt strings. + + * plot/__pltopt1__.m: Greatly simplify. + + * plot/__next_line_color__.m: New file. + * plot/Makefile.in (SOURCES_M): Add it to the list. + * plot/newplot.m: Call __next_line_color__ here to reset rotation. + + * plot/__default_plot_options__.m: New file. + * plot/Makefile.in (SOURCES_M): Add it to the list. + + * plot/__plt3__.m: Delete. + * plot/Makefile.in (SOURCES_M): Remove it from the list. + 2007-01-31 John W. Eaton <jwe@octave.org> * plot/__uiobject_draw_axes__.m: Set defaults for color,
--- a/scripts/plot/Makefile.in +++ b/scripts/plot/Makefile.in @@ -22,10 +22,12 @@ SOURCES_M = \ __axis_label__.m \ + __default_colormap__.m \ + __default_plot_options__.m \ __errcomm__.m \ - __default_colormap__.m \ __errplot__.m \ __gnuplot_version__.m \ + __next_line_color__.m \ __plr1__.m \ __plr2__.m \ __plt1__.m \ @@ -35,7 +37,6 @@ __plt2ss__.m \ __plt2vm__.m \ __plt2vv__.m \ - __plt3__.m \ __plt__.m \ __plt_get_axis_arg__.m \ __pltopt1__.m \
new file mode 100644 --- /dev/null +++ b/scripts/plot/__default_plot_options__.m @@ -0,0 +1,35 @@ +## Copyright (C) 2007 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 2, 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, write to the Free +## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} __default_plot_options__ () +## Return a default options structure for __pltopt__. +## @seealso{__pltopt__} +## @end deftypefn + +## Author: jwe + +function options = __default_plot_options__ () + + options.key = ""; + options.color = []; + options.linestyle = "-"; + options.marker = "none"; + +endfunction
new file mode 100644 --- /dev/null +++ b/scripts/plot/__next_line_color__.m @@ -0,0 +1,54 @@ +## Copyright (C) 2007 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 2, 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, write to the Free +## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} __next_line_color__ (@var{reset}) +## Return the next line color in the rotation. +## @end deftypefn + +## Author: jwe + +function rgb = __next_line_color__ (reset) + + persistent color_rotation = [ 0, 0, 1; + 0, 0.5, 0; + 1, 0, 0; + 0, 0.75, 0.75; + 0.75, 0, 0.75; + 0.75, 0.75, 0; + 0.25, 0.25, 0.25]; + + persistent num_colors = rows (color_rotation); + persistent color_index = 1; + + if (nargin < 2) + if (nargin == 1 && reset) + color_index = 1; + else + color_index + rgb = color_rotation(color_index,:) + if (++color_index > num_colors) + color_index = 1; + endif + endif + else + print_usage (); + endif + +endfunction
--- a/scripts/plot/__plt1__.m +++ b/scripts/plot/__plt1__.m @@ -23,26 +23,18 @@ ## Author: jwe -function __plt1__ (h, x1, fmt, key) +function __plt1__ (h, x1, options) - if (nargin < 2 || nargin > 4) + if (nargin < 2 || nargin > 3) print_usage (); endif - if (nargin < 3 || isempty (fmt)) - fmt = {""}; + if (nargin < 3 || isempty (options)) + options = __default_plot_options__ (); endif - if (nargin < 4 || isempty (key)) - key = {""}; - endif - - if (! iscellstr (fmt)) - error ("__plt1__: fmt must be a cell array of character strings"); - endif - - if (! iscell (key)) - error ("__plt1__: fmt must be a cell array"); + if (! isstruct (options)) + error ("__plt1__: options must be a struct array"); endif [nr, nc] = size (x1); @@ -61,6 +53,6 @@ x1 = (1:nr)'; endif - __plt2__ (h, x1, x2, fmt, key); + __plt2__ (h, x1, x2, options); endfunction
--- a/scripts/plot/__plt2__.m +++ b/scripts/plot/__plt2__.m @@ -18,31 +18,23 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} __plt2__ (@var{h}, @var{x1}, @var{x2}, @var{fmt}, @var{key}) +## @deftypefn {Function File} {} __plt2__ (@var{h}, @var{x1}, @var{x2}, @var{options}) ## @end deftypefn ## Author: jwe -function __plt2__ (h, x1, x2, fmt, key) +function __plt2__ (h, x1, x2, options) - if (nargin < 3 || nargin > 5) + if (nargin < 3 || nargin > 4) print_usage (); endif - if (nargin < 4 || isempty (fmt)) - fmt = {""}; + if (nargin < 4 || isempty (options)) + options = __default_plot_options__ (); endif - if (nargin < 5 || isempty (key)) - key = {""}; - endif - - if (! iscellstr (fmt)) - error ("__plt1__: fmt must be a cell array of character strings"); - endif - - if (! iscell (key)) - error ("__plt1__: fmt must be a cell array"); + if (! isstruct (options)) + error ("__plt1__: options must be a struct array"); endif if (any (any (imag (x1)))) @@ -55,23 +47,23 @@ if (isscalar (x1)) if (isscalar (x2)) - __plt2ss__ (h, x1, x2, fmt, key); + __plt2ss__ (h, x1, x2, options); else error ("__plt2__: invalid data for plotting"); endif elseif (isvector (x1)) if (isvector (x2)) - __plt2vv__ (h, x1, x2, fmt, key); + __plt2vv__ (h, x1, x2, options); elseif (ismatrix (x2)) - __plt2vm__ (h, x1, x2, fmt, key); + __plt2vm__ (h, x1, x2, options); else error ("__plt2__: invalid data for plotting"); endif elseif (ismatrix (x1)) if (isvector (x2)) - __plt2mv__ (h, x1, x2, fmt, key); + __plt2mv__ (h, x1, x2, options); elseif (ismatrix (x2)) - __plt2mm__ (h, x1, x2, fmt, key); + __plt2mm__ (h, x1, x2, options); else error ("__plt2__: invalid data for plotting"); endif
--- a/scripts/plot/__plt2mm__.m +++ b/scripts/plot/__plt2mm__.m @@ -18,45 +18,42 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} __plt2mm__ (@var{h}, @var{x}, @var{y}, @var{fmt}, @var{key}) +## @deftypefn {Function File} {} __plt2mm__ (@var{h}, @var{x}, @var{y}, @var{options}) ## @end deftypefn ## Author: jwe -function __plt2mm__ (h, x, y, fmt, key) +function __plt2mm__ (h, x, y, options) - if (nargin < 3 || nargin > 5) + if (nargin < 3 || nargin > 4) print_usage (); endif - if (nargin < 4 || isempty (fmt)) - fmt = {""}; - endif - - if (nargin < 5 || isempty (key)) - key = {""}; + if (nargin < 4 || isempty (options)) + options = __default_plot_options__ (); endif [x_nr, x_nc] = size (x); [y_nr, y_nc] = size (y); k = 1; - fmt_nr = rows (fmt); if (x_nr == y_nr && x_nc == y_nc) if (x_nc > 0) - if (rows (fmt) == 1) - fmt = repmat (fmt, x_nc, 1); - endif - if (rows (key) == 1) - key = repmat (key, x_nc, 1); + if (numel (options) == 1) + options = repmat (options(:), x_nc, 1); endif for i = 1:x_nc - ## FIXME -- need to handle labels and line format. - tkey = key{i}; + tkey = options(i).key; if (! isempty (tkey)) set (h, "key", "on"); endif - line (x(:,i), y(:,i), "keylabel", tkey); + color = options(i).color; + if (isempty (color)) + color = __next_line_color__ (); + endif + line (x(:,i), y(:,i), "keylabel", tkey, "color", color, + "linestyle", options(i).linestyle, + "marker", options(i).marker); endfor else error ("__plt2mm__: arguments must be a matrices");
--- a/scripts/plot/__plt2mv__.m +++ b/scripts/plot/__plt2mv__.m @@ -18,23 +18,19 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} __plt2mv__ (@var{h}, @var{x}, @var{y}, @var{fmt}, @var{key}) +## @deftypefn {Function File} {} __plt2mv__ (@var{h}, @var{x}, @var{y}, @var{options}) ## @end deftypefn ## Author: jwe -function __plt2mv__ (h, x, y, fmt, key) +function __plt2mv__ (h, x, y, options) - if (nargin < 3 || nargin > 5) + if (nargin < 3 || nargin > 4) print_usage (); endif - if (nargin < 4 || isempty (fmt)) - fmt = {""}; - endif - - if (nargin < 5 || isempty (key)) - key = {""}; + if (nargin < 4 || isempty (options)) + options = __default_plot_options__ (); endif [x_nr, x_nc] = size (x); @@ -59,19 +55,21 @@ endif if (x_nc > 0) - if (rows (fmt) == 1) - fmt = repmat (fmt, x_nc, 1); - endif - if (rows (key) == 1) - key = repmat (key, x_nc, 1); + if (numel (options) == 1) + options = repmat (options(:), x_nc, 1); endif for i = 1:x_nc - ## FIXME -- need to handle labels and line format. - tkey = key{i}; + tkey = options(i).key; if (! isempty (tkey)) set (h, "key", "on"); endif - line (x(:,i), y, "keylabel", tkey); + color = options(i).color; + if (isempty (color)) + color = __next_line_color__ (); + endif + line (x(:,i), y, "keylabel", tkey, "color", color, + "linestyle", options(i).linestyle, + "marker", options(i).marker); endfor else error ("__plt2mv__: arguments must be a matrices");
--- a/scripts/plot/__plt2ss__.m +++ b/scripts/plot/__plt2ss__.m @@ -18,43 +18,41 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} __plt2ss__ (@var{h}, @var{x}, @var{y}, @var{fmt}, @var{key}) +## @deftypefn {Function File} {} __plt2ss__ (@var{h}, @var{x}, @var{y}, @var{options}) ## @end deftypefn ## Author: jwe -function __plt2ss__ (h, x, y, fmt, key) +function __plt2ss__ (h, x, y, options) - if (nargin < 3 || nargin > 5) + if (nargin < 3 || nargin > 4) print_usage (); endif - if (nargin < 4 || isempty (fmt)) - fmt = {""}; + if (nargin < 4 || isempty (options)) + options = __default_plot_options__ (); endif - if (nargin < 5 || isempty (key)) - key = {""}; - endif - - if (rows (fmt) > 1) - fmt = fmt(1); - endif - - if (rows (key) > 1) - key = key(1); + 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 = key{1}; + key = options.key; if (! isempty (key)) set (h, "key", "on"); endif - ## FIXME -- need to handle labels and line format. - line (x, y, "keylabel", key); + color = options.color; + if (isempty (color)) + color = __next_line_color__ (); + endif + line (x, y, "keylabel", key, "color", color, + "linestyle", options.linestyle, + "marker", options.marker); +); else error ("__plt2ss__: arguments must be scalars"); endif
--- a/scripts/plot/__plt2vm__.m +++ b/scripts/plot/__plt2vm__.m @@ -18,23 +18,19 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} __plt2vm__ (@var{h}, @var{x}, @var{y}, @var{fmt}, @var{key}) +## @deftypefn {Function File} {} __plt2vm__ (@var{h}, @var{x}, @var{y}, @var{options}) ## @end deftypefn ## Author: jwe -function __plt2vm__ (h, x, y, fmt, key) +function __plt2vm__ (h, x, y, options) - if (nargin < 3 || nargin > 5) + if (nargin < 3 || nargin > 4) print_usage (); endif - if (nargin < 4 || isempty (fmt)) - fmt = {""}; - endif - - if (nargin < 5 || isempty (key)) - key = {""}; + if (nargin < 4 || isempty (options)) + options = __default_plot_options__ (); endif [x_nr, x_nc] = size (x); @@ -59,19 +55,21 @@ endif if (y_nc > 0) - if (rows (fmt) == 1) - fmt = repmat (fmt, y_nc, 1); - endif - if (rows (key) == 1) - key = repmat (key, y_nc, 1); + if (numel (options) == 1) + options = repmat (options(:), y_nc, 1); endif for i = 1:y_nc - tkey = key{i}; + tkey = options(i).key if (! isempty (tkey)) set (h, "key", "on"); endif - ## FIXME -- need to handle labels and line format. - line (x, y(:,i), "keylabel", tkey); + color = options(i).color; + if (isempty (color)) + color = __next_line_color__ (); + endif + line (x, y(:,i), "keylabel", tkey, "color", color, + "linestyle", options(i).linestyle, + "marker", options(i).marker); endfor else error ("__plt2vm__: arguments must be a matrices");
--- a/scripts/plot/__plt2vv__.m +++ b/scripts/plot/__plt2vv__.m @@ -18,31 +18,23 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} __plt2vv__ (@var{h}, @var{x}, @var{y}, @var{fmt}, @var{key}) +## @deftypefn {Function File} {} __plt2vv__ (@var{h}, @var{x}, @var{y}, @var{options}) ## @end deftypefn ## Author: jwe -function __plt2vv__ (h, x, y, fmt, key) +function __plt2vv__ (h, x, y, options) - if (nargin < 3 || nargin > 5) + if (nargin < 3 || nargin > 4) print_usage (); endif - if (nargin < 4 || isempty (fmt)) - fmt = {""}; + if (nargin < 4 || isempty (options)) + options = __default_plot_options__ (); endif - if (nargin < 5 || isempty (key)) - key = {""}; - endif - - if (rows (fmt) > 1) - fmt = fmt(1); - endif - - if (rows (key) > 1) - key = key(1); + if (numel (options) > 1) + options = options(1); endif [x_nr, x_nc] = size (x); @@ -63,13 +55,17 @@ endif if (x_nr == y_nr) - key = key{1}; + key = options.key; if (! isempty (key)) set (h, "key", "on"); endif - fmt{1} - ## FIXME -- need to handle labels and line format. - line (x, y, "keylabel", key); + color = options.color; + if (isempty (color)) + color = __next_line_color__ (); + endif + line (x, y, "keylabel", key, "color", color, + "linestyle", options.linestyle, + "marker", options.marker); else error ("__plt2vv__: vector lengths must match"); endif
deleted file mode 100644 --- a/scripts/plot/__plt3__.m +++ /dev/null @@ -1,81 +0,0 @@ -## Copyright (C) 1996 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 2, 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, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __plt3__ (@var{x}, @var{y}, @var{z}, @var{fmt}) -## @end deftypefn - -## Author: Paul Kienzle <kienzle.powernet.co.uk> -## 2001-04-06 Paul Kienzle <kienzle.powernet.co.uk> -## * __gnuplot_set__ nohidden3d; vector X,Y, matrix Z => meshgrid(X,Y) - -## Modified to use new gnuplot interface in octave > 2.9.0 -## Dmitri A. Sergatskov <dasergatskov@gmail.com> -## April 18, 2005 -## Modified to use NaN as seperator for gnuplot, so multiple calls -## aren't needed. -## David Bateman <dbateman@free.fr> -## May 25, 2006 - -function __plt3__ (x, usingstr, fmt, key, withstr) - - if (nargin < 2) - have_usingstr = false; - usingstr = ""; - else - have_usingstr = true; - endif - if (nargin < 3 || isempty (fmt)) - fmt = ""; - endif - if (nargin < 4 || isempty (key)) - key = ""; - endif - if (nargin < 5) - withstr = ""; - endif - - __plot_globals__; - - cf = __current_figure__; - mxi = __multiplot_xi__(cf); - myi = __multiplot_yi__(cf); - - __setup_plot__ ("splot"); - - j = __plot_data_offset__{cf}(mxi,myi); - - __plot_data__{cf}{mxi,myi}{j}{1} = x; - __plot_data_type__{cf}{mxi,myi}(j) = 3; - __plot_data_parametric__{cf}{mxi,myi}{j}{1} = parametric; - __plot_key_labels__{cf}{mxi,myi}{j}{1} = keystr; - - __plot_fmtstr__{cf}{mxi,myi}{j}{1} = fmtstr; - if (have_usingstr) - __plot_usingstr__{cf}{mxi,myi}{j}{1} = usingstr; - else - __plot_usingstr__{cf}{mxi,myi}{j}{1} = __make_using_clause__(x); - endif - __plot_withstr__{cf}{mxi,myi}{j}{1} = withstr; - - __plot_data_offset__{cf}(mxi,myi) = ++j; - - __render_plot__ (); - -endfunction
--- a/scripts/plot/__plt__.m +++ b/scripts/plot/__plt__.m @@ -49,11 +49,11 @@ if (ischar (next_arg) || iscellstr (next_arg)) if (x_set) - [fmt, key] = __pltopt__ (caller, next_arg); + options = __pltopt__ (caller, next_arg); if (y_set) - __plt2__ (h, x, y, fmt, key); + __plt2__ (h, x, y, options); else - __plt1__ (h, x, fmt, key); + __plt1__ (h, x, options); endif x_set = false; y_set = false; @@ -62,8 +62,8 @@ endif elseif (x_set) if (y_set) - [fmt, key] = __pltopt__ (caller, {""}); - __plt2__ (h, x, y, fmt, key); + options = __pltopt__ (caller, {""}); + __plt2__ (h, x, y, options); x = next_arg; y_set = false; else
--- a/scripts/plot/__pltopt1__.m +++ b/scripts/plot/__pltopt1__.m @@ -27,40 +27,12 @@ ## Adapted-By: jwe ## Maintainer: jwe -function [fmt, keystr] = __pltopt1__ (caller, opt) +function options = __pltopt1__ (caller, opt) - set_color = 0; - set_symbol = 0; - set_lines = 0; - set_dots = 0; - set_points = 0; - set_impulses = 0; - set_steps = 0; - set_boxes = 0; - set_yerrbars = 0; - set_xerrbars = 0; - set_linestyle = "solid"; - - fmt = ""; - keystr = ""; + options = __default_plot_options__ (); more_opts = 1; - WITH = "w"; - LINES = "l"; - LINESPOINTS = "linesp"; - BOXERRORBARS = "boxer"; - BOXES = "boxes"; - BOXXY = "boxxy"; - POINTS = "p"; - DOTS = "d"; - IMPULSES = "i"; - STEPS = "s"; - YERRORBARS = "yerr"; - XERRORBARS = "xerr"; - XYERRORBARS = "xyerr"; - TITLE = "title"; - if (nargin != 2) print_usage (); endif @@ -69,190 +41,52 @@ return; endif - while (more_opts) - - ## First get next char. - - if (max (size (opt)) > 1) - ## [char, opt] = sscanf (opt, "%c %s", "C"); - char = opt(1); - opt = opt(2:length(opt)); + while (! isempty (opt)) + if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2)) + options.linestyle = opt(1:2); + n = 2; else - char = opt; - more_opts = 0; - endif - - ## Now set flags based on char. - - if (strcmp (char, "-")) - if (set_lines) - set_linestyle = "dash"; - else - set_lines = 1; - endif - elseif (strcmp (char, ".")) - if (set_lines) - set_linestyle = "dashdot"; + topt = opt(1); + n = 1; + if (topt == "-" || topt == ":") + options.linestyle = topt; + elseif (topt == "+" || topt == "o" || topt == "*" + || topt == "." || topt == "x" || topt == "s" + || topt == "d" || topt == "^" || topt == "v" + || topt == ">" || topt == "<" || topt == "p" + || topt == "h") + options.marker = topt; + elseif (topt == "k") + options.color = [0, 0, 0]; + elseif (topt == "r") + options.color = [1, 0, 0]; + elseif (topt == "g") + options.color = [0, 1, 0]; + elseif (topt == "b") + options.color = [0, 0, 1]; + elseif (topt == "y") + options.color = [1, 1, 0]; + elseif (topt == "m") + options.color = [1, 0, 1]; + elseif (topt == "c") + options.color = [0, 1, 1]; + elseif (topt == "w") + 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 + error ("%s: unfinished key label", caller); + endif else - set_dots = 1; - endif - elseif (strcmp (char, ":")) - set_lines = 1; - set_linestyle = "dot"; - elseif (strcmp (char, "@")) - set_points = 1; - elseif (strcmp (char, "^")) - set_impulses = 1; - elseif (strcmp (char, "L")) - set_steps = 1; - elseif (strcmp (char, "~")) - set_yerrbars = 1; - elseif (strcmp (char, ">")) - set_xerrbars = 1; - elseif (strcmp (char, "#")) - set_boxes = 1; - elseif (strcmp (char, "0") || strcmp (char, "1") ... - || strcmp (char, "2") || strcmp (char, "3") ... - || strcmp (char, "4") || strcmp (char, "5") ... - || strcmp (char, "6") || strcmp (char, "7") ... - || strcmp (char, "8") || strcmp (char, "9")) - if (set_color) - set_points = 1; - symbol = char; - set_symbol = 1; - else - color = char; - set_color = 1; + error ("%s: unrecognized format character: `%s'", caller, topt); endif - elseif (strcmp (char, "k")) - set_color = 1; - color = "-1"; - elseif (strcmp (char, "r")) - set_color = 1; - color = "1"; - elseif (strcmp (char, "g")) - set_color = 1; - color = "2"; - elseif (strcmp (char, "b")) - set_color = 1; - color = "3"; - elseif (strcmp (char, "m")) - set_color = 1; - color = "4"; - elseif (strcmp (char, "c")) - set_color = 1; - color = "5"; - elseif (strcmp (char, "w")) - set_color = 1; - color = "6"; - elseif (strcmp (char, "*")) - set_points = 1; - set_symbol = 1; - symbol = "3"; - elseif (strcmp (char, "+")) - set_points = 1; - set_symbol = 1; - symbol = "1"; - elseif (strcmp (char, "o")) - set_points = 1; - set_symbol = 1; - symbol = "6"; - elseif (strcmp (char, "x")) - set_points = 1; - set_symbol = 1; - symbol = "2"; - elseif (strcmp (char, "s")) - set_points = 1; - set_symbol = 1; - symbol = "4"; - elseif (strcmp (char, "d")) - set_points = 1; - set_symbol = 1; - symbol = "12"; - elseif (strcmp (char, "v")) - set_points = 1; - set_symbol = 1; - symbol = "10"; - elseif (strcmp (char, ";")) # title mode. - working = 1; - while (working) - if (max (size (opt)) > 1) - char = opt(1); - opt = opt(2:length(opt)); - else - char = opt; - if (! strcmp (char, ";")) - error ("%s: unfinished key label", caller); - endif - more_opts = 0; - working = 0; - endif - if strcmp (char, ";") - working = 0; - else - keystr = strcat (keystr, char); - endif - endwhile - keystr = undo_string_escapes (keystr); - elseif (strcmp (char, " ")) - elseif (isempty(char)) - ## whitespace -- do nothing. - else - error ("%s: unrecognized format character: '%s'", caller, char); endif + opt(1:n) = []; endwhile - ## Now create format string. - - fmt = WITH; - - if (set_lines) - if (set_points) - fmt = strcat (fmt, " ", LINESPOINTS); - else - fmt = strcat (fmt, " ", LINES); - endif - elseif (set_boxes) - if (set_yerrbars && set_xerrbars) - fmt = strcat (fmt, " ", BOXXY); - elseif (set_yerrbars ) - fmt = strcat (fmt, " ", BOXERRORBARS); - else - fmt = strcat (fmt, " ", BOXES); - endif - elseif (set_points) - fmt = strcat (fmt, " ", POINTS); - elseif (set_dots) - fmt = strcat (fmt, " ", DOTS); - elseif (set_impulses) - fmt = strcat (fmt, " ", IMPULSES); - elseif (set_steps) - fmt = strcat (fmt, " ", STEPS); - elseif (set_yerrbars) - if (set_xerrbars) - fmt = strcat (fmt, " ", XYERRORBARS); - else - fmt = strcat (fmt, " ", YERRORBARS); - endif - elseif (set_xerrbars) - fmt = strcat (fmt, " ", XERRORBARS); - endif - - if (strcmp (fmt, WITH)) - if (strcmp (caller, "__errplot__")) - fmt = strcat (fmt, " ", YERRORBARS); - else - fmt = strcat (fmt, " ", LINES); - endif - endif - - if (set_color) - fmt = strcat (fmt, " ", color); - if (set_symbol) - fmt = strcat (fmt, " ", symbol); - endif - elseif (set_symbol) - fmt = strcat (fmt, " 1 ", symbol); - endif - endfunction
--- a/scripts/plot/__pltopt__.m +++ b/scripts/plot/__pltopt__.m @@ -108,9 +108,9 @@ ## Author: jwe -function [fmt, keystr] = __pltopt__ (caller, opt) +function options = __pltopt__ (caller, opt) - if (nargin == 2 && nargout == 2) + if (nargin == 2 && nargout == 1) if (ischar (opt)) nel = rows (opt); elseif (iscellstr (opt)) @@ -118,15 +118,11 @@ else error ("__pltopt__: expecting argument to be character string or cell array of character strings"); endif - fmt = cell (nel, 1); - keystr = cell (nel, 1); if (ischar (opt)) opt = cellstr (opt); endif - for i = 1:nel - [tfmt, tkey] = __pltopt1__ (caller, opt{i}); - fmt{i} = tfmt; - keystr{i} = tkey; + for i = nel:-1:1 + options(i) = __pltopt1__ (caller, opt{i}); endfor else print_usage ();
--- a/scripts/plot/__uiobject_draw_axes__.m +++ b/scripts/plot/__uiobject_draw_axes__.m @@ -725,7 +725,7 @@ pt = "10"; case {"pentagram", "p"} pt = "4"; - case {"hexagram", "h"'} + case {"hexagram", "h"} pt = "6"; case "none" pt = "";
--- a/scripts/plot/newplot.m +++ b/scripts/plot/newplot.m @@ -41,6 +41,7 @@ case "add" case "replacechildren" case "replace" + __next_line_color__ (true); __uiobject_axes_init__ (ca); otherwise error ("newplot: unrecognized nextplot property for current axes");
--- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -195,7 +195,7 @@ z_set = 1; endif endif - [fmt, key] = __pltopt__ ("plot3", new); + options = __pltopt__ ("plot3", new); if (isvector (x) && isvector (y)) if (isvector (z)) @@ -213,10 +213,15 @@ error ("plot3: x, y, and z must have the same shape"); endif - line (x(:), y(:), z(:)); + key = options.key; + if (! isempty (key)) + set (gca (), "key", "on"); + endif - ## FIXME -- what about fmt and key? - ## fmt{1}, key{1}); + line (x(:), y(:), z(:), "keylabel", key, + "color", options.color, + "linestyle", options.linestyle, + "marker", options.marker); x_set = 0; y_set = 0;