comparison scripts/plot/contour.m @ 5214:eecc24b92d97

[project @ 2005-03-16 17:14:12 by jwe]
author jwe
date Wed, 16 Mar 2005 17:14:12 +0000
parents c08cb1098afc
children 32c569794216
comparison
equal deleted inserted replaced
5213:390f13fc0f4a 5214:eecc24b92d97
24 ## @var{z}. Someone needs to improve @code{gnuplot}'s contour routines 24 ## @var{z}. Someone needs to improve @code{gnuplot}'s contour routines
25 ## before this will be very useful. 25 ## before this will be very useful.
26 ## @end deftypefn 26 ## @end deftypefn
27 ## 27 ##
28 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour, 28 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
29 ## bar, stairs, gplot, gsplot, replot, xlabel, ylabel, and title} 29 ## bar, stairs, replot, xlabel, ylabel, and title}
30 30
31 ## Author: jwe 31 ## Author: jwe
32 32
33 function contour (x, y, z, n) 33 function contour (x, y, z, n)
34 34
42 n = 10; 42 n = 10;
43 else 43 else
44 n = y; 44 n = y;
45 endif 45 endif
46 if (ismatrix (z)) 46 if (ismatrix (z))
47 gset nosurface; 47 __gset__ nosurface;
48 gset contour; 48 __gset__ contour;
49 gset cntrparam bspline; 49 __gset__ cntrparam bspline;
50 if (isscalar (n)) 50 if (isscalar (n))
51 command = sprintf ("gset cntrparam levels %d", n); 51 command = sprintf ("__gset__ cntrparam levels %d", n);
52 elseif (isvector (n)) 52 elseif (isvector (n))
53 tmp = sprintf ("%f", n(1)); 53 tmp = sprintf ("%f", n(1));
54 for i = 2:length (n) 54 for i = 2:length (n)
55 tmp = sprintf ("%s, %f", tmp, n(i)); 55 tmp = sprintf ("%s, %f", tmp, n(i));
56 endfor 56 endfor
57 command = sprintf ("gset cntrparam levels discrete %s", tmp); 57 command = sprintf ("__gset__ cntrparam levels discrete %s", tmp);
58 else 58 else
59 error ("contour: levels must be a scalar or vector") ; 59 error ("contour: levels must be a scalar or vector") ;
60 endif 60 endif
61 eval (command); 61 eval (command);
62 gset noparametric; 62 __gset__ noparametric;
63 gset view 0, 0, 1, 1; 63 __gset__ view 0, 0, 1, 1;
64 gsplot z w l 1; 64 __gsplot__ z w l 1;
65 else 65 else
66 error ("contour: z of contour (z, levels) must be a matrix"); 66 error ("contour: z of contour (z, levels) must be a matrix");
67 endif 67 endif
68 elseif (nargin == 3 || nargin == 4) 68 elseif (nargin == 3 || nargin == 4)
69 if (nargin == 3) 69 if (nargin == 3)
102 zz(:,3:3:nc) = z'; 102 zz(:,3:3:nc) = z';
103 else 103 else
104 error (size_msg); 104 error (size_msg);
105 endif 105 endif
106 endif 106 endif
107 gset nosurface; 107 __gset__ nosurface;
108 gset contour; 108 __gset__ contour;
109 gset cntrparam bspline; 109 __gset__ cntrparam bspline;
110 if (isscalar (n)) 110 if (isscalar (n))
111 command = sprintf ("gset cntrparam levels %d", n); 111 command = sprintf ("__gset__ cntrparam levels %d", n);
112 elseif (isvector (n)) 112 elseif (isvector (n))
113 tmp = sprintf ("%f", n(1)); 113 tmp = sprintf ("%f", n(1));
114 for i = 2:length (n) 114 for i = 2:length (n)
115 tmp = sprintf ("%s, %f", tmp, n(i)); 115 tmp = sprintf ("%s, %f", tmp, n(i));
116 endfor 116 endfor
117 command = sprintf ("gset cntrparam levels discrete %s", tmp); 117 command = sprintf ("__gset__ cntrparam levels discrete %s", tmp);
118 else 118 else
119 error ("contour: levels must be a scalar or vector") ; 119 error ("contour: levels must be a scalar or vector") ;
120 endif 120 endif
121 eval (command); 121 eval (command);
122 gset parametric; 122 __gset__ parametric;
123 gset view 0, 0, 1, 1; 123 __gset__ view 0, 0, 1, 1;
124 gsplot zz w l 1; 124 __gsplot__ zz w l 1;
125 else 125 else
126 error ("contour: x and y must be vectors and z must be a matrix"); 126 error ("contour: x and y must be vectors and z must be a matrix");
127 endif 127 endif
128 else 128 else
129 usage ("contour (x, y, z, levels) or contour (z, levels)"); 129 usage ("contour (x, y, z, levels) or contour (z, levels)");