1
## Copyright (C) 1996, 1997 John W. Eaton
3
## This file is part of Octave.
5
## Octave is free software; you can redistribute it and/or modify it
6
## under the terms of the GNU General Public License as published by
7
## the Free Software Foundation; either version 2, or (at your option)
10
## Octave is distributed in the hope that it will be useful, but
11
## WITHOUT ANY WARRANTY; without even the implied warranty of
12
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
## General Public License for more details.
15
## You should have received a copy of the GNU General Public License
16
## along with Octave; see the file COPYING. If not, write to the Free
17
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21
## @deftypefn {Function File} {} contour (@var{z}, @var{n})
22
## @deftypefnx {Function File} {} contour (@var{x}, @var{y}, @var{z}, @var{n})
23
## Make a contour plot of the three-dimensional surface described by
24
## @var{z}. Someone needs to improve @code{gnuplot}'s contour routines
25
## before this will be very useful.
27
## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
28
## bar, stairs, gplot, gsplot, replot, xlabel, ylabel, and title}
32
## Modified Jan. 2003 -- Added TeXmacs interface support
33
## Author: Michael Graffam <mgraffam@mathlab.sunysb.edu>
35
function contour (x, y, z, n)
37
## XXX FIXME XXX -- these plot states should really just be set
38
## temporarily, probably inside an unwind_protect block, but there is
39
## no way to determine their current values.
41
if (length(getenv("TEXMACS_PATH"))>0)
42
gset output '/tmp/tmplot.eps';
45
if (nargin == 1 || nargin == 2)
55
gset cntrparam bspline;
57
command = sprintf ("gset cntrparam levels %d", n);
58
elseif (is_vector (n))
59
tmp = sprintf ("%f", n(1));
61
tmp = sprintf ("%s, %f", tmp, n(i));
63
command = sprintf ("gset cntrparam levels discrete %s", tmp);
69
if (length(getenv("TEXMACS_PATH"))>0)
70
P=[2;112;115;58]; #P= "\002ps:"
71
g=fopen("/tmp/tmplot.eps");
74
g=fopen("/tmp/tmplot.eps");
84
disp(sprintf("%cverbatim:\n",2));
86
system("rm /tmp/tmplot.eps");
90
error ("contour: argument must be a matrix");
93
if (is_vector (x) && is_vector (y) && is_matrix (z))
96
if (xlen == rows (z) && ylen == columns (z))
101
zz = zeros (xlen, len);
105
zz(:,i+1) = y(k) * ones (xlen, 1);
111
gset cntrparam bspline;
113
command = sprintf ("gset cntrparam levels %d", n);
114
elseif (is_vector (n))
115
tmp = sprintf ("%f", n(1));
117
tmp = sprintf ("%s, %f", tmp, n(i));
119
command = sprintf ("gset cntrparam levels discrete %s", tmp);
123
gset view 0, 0, 1, 1;
125
if (length(getenv("TEXMACS_PATH"))>0)
126
P=[2;112;115;58]; #P= "\002ps:"
127
g=fopen("/tmp/tmplot.eps");
130
g=fopen("/tmp/tmplot.eps");
140
disp(sprintf("%cverbatim:\n",2));
142
system("rm /tmp/tmplot.eps");
146
msg = "contour: rows (z) must be the same as length (x) and";
147
msg = sprintf ("%s\ncolumns (z) must be the same as length (y)", msg);
151
error ("contour: x and y must be vectors and z must be a matrix");
154
usage ("contour (z, levels, x, y)");