Mercurial > hg > octave-terminal
changeset 7146:c7e5e638a8d0
[project @ 2007-11-09 17:49:44 by jwe]
author | jwe |
---|---|
date | Fri, 09 Nov 2007 17:51:42 +0000 |
parents | d169c9f4a697 |
children | fdb3840cec66 |
files | doc/ChangeLog scripts/ChangeLog scripts/plot/Makefile.in scripts/plot/__area__.m scripts/plot/area.m scripts/plot/mesh.m scripts/plot/meshc.m scripts/plot/pcolor.m scripts/plot/surf.m scripts/plot/surface.m scripts/plot/surfc.m |
diffstat | 11 files changed, 180 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2007-11-09 David Bateman <dbateman@free.fr> + + * interpreter/plot.txi: Document the new area function. + 2007-11-07 David Bateman <dbateman@free.fr> * interpreter/plot.txi: Document new functions.
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,17 @@ +2007-11-09 John W. Eaton <jwe@octave.org> + + * plot/surfc.m, plot/meshc.m: Don't change view if hold is on. + +2007-11-09 Kai Habel <kai.habel@gmx.de> + + * 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 <dbateman@free.fr> + * 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 <Jskud@Jskud.com>
--- a/scripts/plot/Makefile.in +++ b/scripts/plot/Makefile.in @@ -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 \
new file mode 100644 --- /dev/null +++ b/scripts/plot/__area__.m @@ -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 +## <http://www.gnu.org/licenses/>. + +## 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
new file mode 100644 --- /dev/null +++ b/scripts/plot/area.m @@ -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 +## <http://www.gnu.org/licenses/>. + +## -*- 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
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -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;
--- a/scripts/plot/meshc.m +++ b/scripts/plot/meshc.m @@ -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{:});
--- a/scripts/plot/pcolor.m +++ b/scripts/plot/pcolor.m @@ -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;
--- a/scripts/plot/surf.m +++ b/scripts/plot/surf.m @@ -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;
--- a/scripts/plot/surface.m +++ b/scripts/plot/surface.m @@ -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;
--- a/scripts/plot/surfc.m +++ b/scripts/plot/surfc.m @@ -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