# HG changeset patch # User jwe # Date 1194630702 0 # Node ID c7e5e638a8d03bfafa517363d19b81f4441c1b83 # Parent d169c9f4a697cd17d27093d4ed2b21cd7583138b [project @ 2007-11-09 17:49:44 by jwe] diff -r d169c9f4a697 -r c7e5e638a8d0 doc/ChangeLog --- a/doc/ChangeLog Fri Nov 09 17:43:07 2007 +0000 +++ b/doc/ChangeLog Fri Nov 09 17:51:42 2007 +0000 @@ -1,3 +1,7 @@ +2007-11-09 David Bateman + + * interpreter/plot.txi: Document the new area function. + 2007-11-07 David Bateman * interpreter/plot.txi: Document new functions. diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/ChangeLog --- a/scripts/ChangeLog Fri Nov 09 17:43:07 2007 +0000 +++ b/scripts/ChangeLog Fri Nov 09 17:51:42 2007 +0000 @@ -1,5 +1,17 @@ +2007-11-09 John W. Eaton + + * plot/surfc.m, plot/meshc.m: Don't change view if hold is on. + +2007-11-09 Kai Habel + + * plot/mesh.m, plot/pcolor.m, plot/surf.m, plot/surface.m: + Don't change view if hold is on. + 2007-11-09 David Bateman + * plot/area.m, plot/__area__.m: New functions + * plot/Makefile.in (SOURCES): Add them to the list of files. + * plot/patch.m: Correctly handle case of axis handle as first arg. 2007-11-09 Joseph P. Skudlarek diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/Makefile.in --- a/scripts/plot/Makefile.in Fri Nov 09 17:43:07 2007 +0000 +++ b/scripts/plot/Makefile.in Fri Nov 09 17:51:42 2007 +0000 @@ -34,6 +34,7 @@ INSTALL_DATA = @INSTALL_DATA@ SOURCES = \ + __area__.m \ __axes_limits__.m \ __axis_label__.m \ __bar__.m \ @@ -61,6 +62,7 @@ __pltopt1__.m \ __pltopt__.m \ ancestor.m \ + area.m \ axes.m \ axis.m \ bar.m \ diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/__area__.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/plot/__area__.m Fri Nov 09 17:51:42 2007 +0000 @@ -0,0 +1,33 @@ +## Copyright (C) 2007 David Bateman +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## Undocumented internal function. + +function retval = __area__ (ax, x, y, bv, varargin) + colors = [1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1]; + x = [x(1,:) ; x ; x(end,:)]; + y = cumsum ([[bv, ones(1, size (y, 2) - 1)] ; y ; ... + [bv, ones(1, size (y, 2) - 1)]], 2); + + retval = patch (ax, x(:, 1), y (:, 1), colors (1,:), varargin{:}); + for i = 2 : size(y, 2) + retval = [retval; patch(ax, [x(:,i); flipud(x(:,i))], ... + [y(:, i) ; flipud(y(:, i-1))], colors(i,:), + varargin{:})]; + endfor +endfunction diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/area.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/plot/area.m Fri Nov 09 17:51:42 2007 +0000 @@ -0,0 +1,103 @@ +## Copyright (C) 2007 Michael Goffioul +## +## 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{x}, @var{y}) +## @deftypefnx {Function File} {} area (@var{x}, @var{y}, @var{lvl}) +## @deftypefnx {Function File} {} area (@dots{}, @var{prop}, @var{val}, @dots{}) +## @deftypefnx {Function File} {} area (@var{y}, @dots{}) +## @deftypefnx {Function File} {} area (@var{h}, @dots{}) +## @deftypefnx {Function File} {@var{h} =} area (@dots{}) +## Area plot of cummulative sum of the columns of @var{y}. This shows the +## contributions of a value to a sum, and is functionally similar to +## @code{plot (@var{x}, cumsum (@var{y}, 2))}, except that the area under +## the curve is shaded. +## +## If the @var{x} argument is ommitted it is assumed to be given by +## @code{1 : rows (@var{y})}. A value @var{lvl} can be defined that determines +## where the base level of the shading under the curve should be defined. +## +## Additional arguments to the @code{area} function are passed to the +## @code{patch}. The optional return value @var{h} provides a handle to +## the list of patch objects. +## @seealso{plot, patch} +## @end deftypefn + +function [ h ] = area (varargin) + + if (nargin > 0) + idx = 1; + ax = []; + x = y = []; + bv = 0; + args = {}; + # check for axes parent + if (ishandle (varargin{idx}) && + strcmp (get (varargin{idx}, "type"), "axes")) + ax = varargin{idx}; + idx++; + endif + # check for (X) or (X,Y) arguments and possible base value + if (nargin >= idx && ismatrix (varargin{idx})) + y = varargin{idx}; + idx++; + if (nargin >= idx) + if (isscalar (varargin{idx})) + bv = varargin{idx}; + idx++; + elseif (ismatrix (varargin{idx})) + x = y; + y = varargin{idx}; + idx++; + if (nargin >= idx && isscalar (varargin{idx})) + bv = varargin{idx}; + idx++; + endif + endif + endif + else + print_usage (); + endif + # check for additional args + if (nargin >= idx) + args = {varargin{idx:end}}; + endif + newplot (); + if (isvector (y)) + y = y(:); + endif + if (isempty (x)) + x = repmat ([1:size(y, 1)]', 1, size (y, 2)); + elseif (isvector (x)) + x = repmat (x(:), 1, size (y, 2)); + endif + + if (isempty (ax)) + tmp = __area__ (gca (), x, y, bv, args{:}); + else + tmp = __area__ (ax, x, y, bv, args{:}); + endif + + if (nargout > 0) + h = tmp; + endif + else + print_usage (); + endif + +endfunction diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/mesh.m --- a/scripts/plot/mesh.m Fri Nov 09 17:43:07 2007 +0000 +++ b/scripts/plot/mesh.m Fri Nov 09 17:51:42 2007 +0000 @@ -41,7 +41,9 @@ set (tmp, "facecolor", "none"); set (tmp, "edgecolor", "flat"); - set (ax, "view", [-37.5, 30]); + if (! ishold ()) + set (ax, "view", [-37.5, 30]); + endif if (nargout > 0) h = tmp; diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/meshc.m --- a/scripts/plot/meshc.m Fri Nov 09 17:43:07 2007 +0000 +++ b/scripts/plot/meshc.m Fri Nov 09 17:51:42 2007 +0000 @@ -38,9 +38,11 @@ set (tmp, "facecolor", "none"); set (tmp, "edgecolor", "flat"); - set (ax, "view", [-37.5, 30]); + if (! ishold ()) + set (ax, "view", [-37.5, 30]); + endif - hold on; + hold ("on"); [c, lev] = contourc (varargin{:}); diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/pcolor.m --- a/scripts/plot/pcolor.m Fri Nov 09 17:43:07 2007 +0000 +++ b/scripts/plot/pcolor.m Fri Nov 09 17:51:42 2007 +0000 @@ -45,13 +45,15 @@ print_usage (); endif - tmp = surface (X, Y, Z, c); + tmp = surface (x, y, z, c); ax = get (tmp, "parent"); set (tmp, "facecolor", "flat"); - - set (ax, "view", [0, 90]); + + if (! ishold ()) + set (ax, "view", [0, 90]); + endif if (nargout > 0) h = tmp; diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/surf.m --- a/scripts/plot/surf.m Fri Nov 09 17:43:07 2007 +0000 +++ b/scripts/plot/surf.m Fri Nov 09 17:51:42 2007 +0000 @@ -38,8 +38,9 @@ ax = get (tmp, "parent"); set (tmp, "facecolor", "flat"); - - set (ax, "view", [-37.5, 30]); + if (! ishold ()) + set (ax, "view", [-37.5, 30]); + endif if (nargout > 0) h = tmp; diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/surface.m --- a/scripts/plot/surface.m Fri Nov 09 17:43:07 2007 +0000 +++ b/scripts/plot/surface.m Fri Nov 09 17:51:42 2007 +0000 @@ -84,9 +84,11 @@ ## Make a default surface object. tmp = __go_surface__ (ax, "xdata", x, "ydata", y, "zdata", z, "cdata", c); + set (tmp, "facecolor","flat"); - set (ax, "view", [0, 90], "box", "off"); - set (tmp, "facecolor","flat"); + if (! ishold ()) + set (ax, "view", [0, 90], "box", "off", "xgrid", "on", "ygrid", "on", "zgrid", "on"); + endif if (nargout > 0) h = tmp; diff -r d169c9f4a697 -r c7e5e638a8d0 scripts/plot/surfc.m --- a/scripts/plot/surfc.m Fri Nov 09 17:43:07 2007 +0000 +++ b/scripts/plot/surfc.m Fri Nov 09 17:51:42 2007 +0000 @@ -37,9 +37,11 @@ set (tmp, "facecolor", "flat"); - set (ax, "view", [-37.5, 30]); + if (! ishold ()) + set (ax, "view", [-37.5, 30]); + endif - hold on; + hold ("on"); [c, lev] = contourc (varargin{:}); @@ -47,8 +49,8 @@ levx = linspace (min (lev), max (lev), size (cmap, 1)); - drawnow(); - ax = axis(); + drawnow (); + ax = axis (); zmin = 2 * ax(5) - ax(6); ## decode contourc output format @@ -71,4 +73,5 @@ if (nargout > 0) h = tmp; endif + endfunction