[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: what else is needed before 3.0?
From: |
David Bateman |
Subject: |
Re: what else is needed before 3.0? |
Date: |
Tue, 13 Nov 2007 23:40:12 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
David Bateman wrote:
> David Bateman wrote:
>> John W. Eaton wrote:
>>> I would like to make the 3.0 release soon. What things should be
>>> fixed before we do that? Are there any other important features that
>>> should be added?
>>>
>>> jwe
>>>
>> I have a bug in the changes to the contour code I just changes for
>> unclosed contour lines. I'll sent a fix soon. As for features, I
>> consider that we're in feature freeze already, at least for major
>> features (ie we decided to push addprops to after 3.0).
>
>
> Ok the attached patch treats the unclosed contour issue, modifies
> __contour__ to allow its use in a contour3 function, adds a contour3
> function, treats hidden line removal for patches as well and modifies
> surface.m to allow passing of handles and additional arguments.
Opps, there was a missing ";" in the last version
D.
Index: scripts/plot/Makefile.in
===================================================================
RCS file: /usr/local/cvsroot/octave/scripts/plot/Makefile.in,v
retrieving revision 1.50
diff -u -r1.50 Makefile.in
--- scripts/plot/Makefile.in 13 Nov 2007 17:34:33 -0000 1.50
+++ scripts/plot/Makefile.in 13 Nov 2007 22:38:41 -0000
@@ -72,6 +72,7 @@
clf.m \
close.m \
closereq.m \
+ contour3.m \
contour.m \
contourc.m \
contourf.m \
Index: scripts/plot/__contour__.m
===================================================================
RCS file: /usr/local/cvsroot/octave/scripts/plot/__contour__.m,v
retrieving revision 1.1
diff -u -r1.1 __contour__.m
--- scripts/plot/__contour__.m 13 Nov 2007 17:34:33 -0000 1.1
+++ scripts/plot/__contour__.m 13 Nov 2007 22:38:41 -0000
@@ -23,6 +23,21 @@
ax = varargin {1};
z = varargin {2};
+ if (ischar (z))
+ if (strcmp (z, "none"))
+ z = NaN;
+ elseif (strcmp (z, "base"))
+ if (nargin == 1)
+ z = varargin {1};
+ else
+ z = varargin {3};
+ endif
+ z = 2 * (min(z(:)) - max(z(:)));
+ elseif (!strcmp (z, "level"))
+ error ("unrecognized z argument");
+ endif
+ endif
+
clim = get (ax, "clim");
[c, lev] = contourc (varargin{3:end});
@@ -36,15 +51,23 @@
clev = c(1,i1);
clen = c(2,i1);
- ii = i1+1:i1+clen;
+ if (all (c(:,i1+1) == c(:,i1+clen)))
+ p = c(:, i1+1:i1+clen-1);
+ else
+ p = [c(:, i1+1:i1+clen), NaN(2, 1)];
+ endif
+
lev = (clev - minlev) * (clim(2) - clim(1)) / (maxlev - minlev) + clim(1);
if (isnan (z))
- h = [h; patch(ax, c(1,ii), c(2,ii), "facecolor", "none",
+ h = [h; patch(ax, p(1,:), p(2,:), "facecolor", "none",
"edgecolor", "flat", "cdata", lev)];
- else
- h = [h; patch(ax, c(1,ii), c(2,ii), z*ones(size(ii)), "facecolor",
+ elseif (!ischar(z))
+ h = [h; patch(ax, p(1,:), p(2,:), z * ones (1, columns (p)), "facecolor",
"none", "edgecolor", "flat", "cdata", lev)];
+ else
+ h = [h; patch(ax, p(1,:), p(2,:), clev * ones (1, columns (p)),
+ "facecolor", "none", "edgecolor", "flat", "cdata", lev)];
endif
i1 += clen+1;
endwhile
Index: scripts/plot/__go_draw_axes__.m
===================================================================
RCS file: /usr/local/cvsroot/octave/scripts/plot/__go_draw_axes__.m,v
retrieving revision 1.69
diff -u -r1.69 __go_draw_axes__.m
--- scripts/plot/__go_draw_axes__.m 13 Nov 2007 17:34:33 -0000 1.69
+++ scripts/plot/__go_draw_axes__.m 13 Nov 2007 22:38:42 -0000
@@ -204,7 +204,7 @@
data_idx = 0;
data = cell ();
is_image_data = [];
- hidden_removal = true;
+ hidden_removal = NaN;
xminp = yminp = zminp = cminp = Inf;
xmax = ymax = zmax = cmax = -Inf;
@@ -461,7 +461,12 @@
if (! isnan (xcol) && ! isnan (ycol))
## Is the patch closed or not
- if (! strncmp (obj.facecolor, "none", 4))
+ if (strncmp (obj.facecolor, "none", 4))
+ if (isnan (hidden_removal))
+ hidden_removal = false;
+ endif
+ else
+ hidden_removal = true;
if (! isempty (zcol))
error ("gnuplot (as of v4.2) only supports 2D filled patches");
else
@@ -747,7 +752,11 @@
palette_data = [];
if (strncmp (obj.facecolor, "none", 4))
- hidden_removal = false;
+ if (isnan (hidden_removal))
+ hidden_removal = false;
+ endif
+ else
+ hidden_removal = true;
endif
if (flat_interp_face
@@ -895,7 +904,7 @@
endfor
- if (hidden_removal)
+ if (isnan(hidden_removal) || hidden_removal)
fputs (plot_stream, "set hidden3d;\n");
else
fputs (plot_stream, "unset hidden3d;\n");
Index: scripts/plot/surface.m
===================================================================
RCS file: /usr/local/cvsroot/octave/scripts/plot/surface.m,v
retrieving revision 1.4
diff -u -r1.4 surface.m
--- scripts/plot/surface.m 9 Nov 2007 17:49:45 -0000 1.4
+++ scripts/plot/surface.m 13 Nov 2007 22:38:42 -0000
@@ -18,34 +18,51 @@
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
-## @deftypefn {Function File} @var{h} = {} surface (@var{x}, @var{y}, @var{z},
@var{c})
-## @deftypefnx {Function File} @var{h} = {} surface (@var{x}, @var{y}, @var{z})
-## Plot a surface graphic object given matrices @var{x}, and @var{y} from
@code{meshgrid} and
-## a matrix @var{z} corresponding to the @var{x} and @var{y} coordinates of
-## the surface. If @var{x} and @var{y} are vectors, then a typical vertex
-## is (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus, columns of @var{z}
-## correspond to different @var{x} values and rows of @var{z} correspond
-## to different @var{y} values.
+## @deftypefn {Function File} {} surface (@var{x}, @var{y}, @var{z}, @var{c})
+## @deftypefnx {Function File} {} surface (@var{x}, @var{y}, @var{z})
+## @deftypefnx {Function File} {} surface (@var{z}, @var{c})
+## @deftypefnx {Function File} {} surface (@var{z})
+## @deftypefnx {Function File} {} surface (@dots{}, @var{prop}, @var{val})
+## @deftypefnx {Function File} {} surface (@var{h}, @dots{})
+## @deftypefnx {Function File} address@hidden = } surface (@dots{})
+## Plot a surface graphic object given matrices @var{x}, and @var{y} from
+## @code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and
+## @var{y} coordinates of the surface. If @var{x} and @var{y} are vectors,
+## then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus,
+## columns of @var{z} correspond to different @var{x} values and rows of
+## @var{z} correspond to different @var{y} values. If @var{x} and @var{y}
+## are missing, they are constructed from size of the matrix @var{z}.
+##
+## Any additional properties passed are assigned the the surface..
## @seealso{surf, mesh, patch, line}
## @end deftypefn
## Author: jwe
-function h = surface (x, y, z, c)
+function h = surface (varargin)
ax = gca ();
- if (nargin == 1)
- c = z = x;
- if (ismatrix (z))
- [nr, nc] = size (z);
- x = 1:nc;
- y = (1:nr)';
- else
- error ("surface: argument must be a matrix");
+ firststring = nargin + 1;
+ for i = 1 : nargin
+ if (ischar (varargin {i}))
+ firststring = i;
+ break;
+ endif
+ endfor
+
+
+ if (firststring > 5)
+ print_usage ();
+ elseif (firststring == 5)
+ x = varargin{1};
+ y = varargin{2};
+ z = varargin{3};
+ c = varargin{4};
+
+ if (! size_equal (z, c))
+ error ("surface: z and c must have same size");
endif
- elseif (nargin == 3)
- c = z;
if (isvector (x) && isvector (y) && ismatrix (z))
if (rows (z) == length (y) && columns (z) == length (x))
x = x(:)';
@@ -60,10 +77,11 @@
else
error ("surface: x and y must be vectors and z must be a matrix");
endif
- elseif (nargin == 4)
- if (! size_equal (z, c))
- error ("surface: z and c must have same size");
- endif
+ elseif (firststring == 4)
+ x = varargin{1};
+ y = varargin{2};
+ z = varargin{3};
+ c = z;
if (isvector (x) && isvector (y) && ismatrix (z))
if (rows (z) == length (y) && columns (z) == length (x))
x = x(:)';
@@ -78,6 +96,26 @@
else
error ("surface: x and y must be vectors and z must be a matrix");
endif
+ elseif (firststring == 3)
+ z = varargin {1};
+ c = varargin {2};
+ if (ismatrix (z))
+ [nr, nc] = size (z);
+ x = 1:nc;
+ y = (1:nr)';
+ else
+ error ("surface: argument must be a matrix");
+ endif
+ elseif (firststring == 2)
+ z = varargin {1};
+ c = z;
+ if (ismatrix (z))
+ [nr, nc] = size (z);
+ x = 1:nc;
+ y = (1:nr)';
+ else
+ error ("surface: argument must be a matrix");
+ endif
else
print_usage ();
endif
@@ -85,6 +123,7 @@
## Make a default surface object.
tmp = __go_surface__ (ax, "xdata", x, "ydata", y, "zdata", z, "cdata", c);
set (tmp, "facecolor","flat");
+ set (tmp, varargin {firststring:end});
if (! ishold ())
set (ax, "view", [0, 90], "box", "off", "xgrid", "on", "ygrid", "on",
"zgrid", "on");
--- /dev/null 2007-11-13 20:30:00.779470432 +0100
+++ scripts/plot/contour3.m 2007-11-13 23:10:59.223367423 +0100
@@ -0,0 +1,77 @@
+## 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/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} address@hidden =} contour3 (@var{z})
+## @deftypefnx {Function File} address@hidden =} contour3 (@var{z}, @var{vn})
+## @deftypefnx {Function File} address@hidden =} contour3 (@var{x}, @var{y},
@var{z})
+## @deftypefnx {Function File} address@hidden =} contour3 (@var{x}, @var{y},
@var{z}, @var{vn})
+## @deftypefnx {Function File} address@hidden =} contour3 (@var{h}, @dots{})
+## @deftypefnx {Function File} address@hidden, @var{h}] =} contour3 (@dots{})
+## Plot level curves (contour lines) of the matrix @var{z}, using the
+## contour matrix @var{c} computed by @code{contourc} from the same
+## arguments; see the latter for their interpretation. The contours are
+## ploted at the Z level corresponding to their contour. The set of
+## contour levels, @var{c}, is only returned if requested. For example:
+##
+## @example
+## @group
+## contour3 (peaks (19));
+## hold on
+## surface (peaks (19), 'FaceColor', 'none', 'EdgeColor', 'black')
+## colormap hot
+## @end group
+## @end example
+##
+## The optional input and output argument @var{h} allows an axis handle to
+## be passed to @code{contour} and the handles to the contour objects to be
+## returned.
+## @seealso{contourc, patch, plot}
+## @end deftypefn
+
+function [c, h] = contour3 (varargin)
+
+ if (isscalar (varargin{1}) && ishandle (varargin{1}))
+ ax = varargin{1};
+ if (! strcmp (get (ax, "type"), "axes"))
+ error ("contour: expecting first argument to be an axes object");
+ endif
+ oldh = gca ();
+ unwind_protect
+ axes (ax);
+ newplot ();
+ [ctmp, htmp] = __contour__ (ax, varargin{2:end});
+ unwind_protect_cleanup
+ axes (oldh);
+ end_unwind_protect
+ else
+ newplot ();
+ ax = gca ();
+ [ctmp, htmp] = __contour__ (ax, "level", varargin{:});
+ endif
+
+ if (! ishold ())
+ set (ax, "view", [-37.5, 30]);
+ endif
+
+ if (nargout > 0)
+ c = ctmp;
+ h = htmp
+ endif
+
+endfunction
2007-11-12 David Bateman <address@hidden>
* plot/__contour__.m: Treat unclosed contours by adding NaN to
flag to patch that it is not closed. Allow z to take string
arguments and use it to flag that the contours are placed at the
z level of the contour itself.
* plot/__go_draw_axes__.m: Treat hidden line removal in patch
objects as well. Let hidden removal take precedence in case of a
conflict.
* plot/surface.m: Allow surface to treat handles being passed or
returned. Any additional arguments arr used to set the surface
handle.
* plot/contour3.m: New function
* plot/Makefile.in (SOURCES): Add it to the sources.