changeset 7245:d65670971cbc

[project @ 2007-12-04 03:03:54 by jwe]
author jwe
date Tue, 04 Dec 2007 03:03:55 +0000
parents 5a9561046b89
children f81e80674b9b
files scripts/ChangeLog scripts/plot/contour.m scripts/plot/contour3.m scripts/plot/contourc.m scripts/plot/contourf.m scripts/plot/cylinder.m scripts/plot/fplot.m scripts/plot/plot3.m scripts/plot/plotyy.m scripts/plot/quiver3.m scripts/plot/scatter.m scripts/plot/scatter3.m scripts/plot/slice.m scripts/plot/sombrero.m scripts/plot/stairs.m scripts/plot/stem.m scripts/plot/stem3.m
diffstat 17 files changed, 124 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/ChangeLog	Tue Dec 04 03:03:55 2007 +0000
@@ -1,3 +1,10 @@
+2007-12-03  John W. Eaton  <jwe@octave.org>
+
+	* contour.m, contour3.m, contourc.m, contourf.m, cylinder.m,
+	fplot.m, plot3.m, plotyy.m, quiver3.m, scatter.m, scatter3.m,
+	slice.m, sombrero.m, stairs.m, stem.m, stem3.m:
+	Generate demos from examples.
+
 2007-12-03  David Bateman  <dbateman@free.fr>
 
 	* testfun/test.m: Disable "testif" test block to avoid spurious
--- a/scripts/plot/contour.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/contour.m	Tue Dec 04 03:03:55 2007 +0000
@@ -35,7 +35,6 @@
 ## y = x;
 ## z = x' * y;
 ## contour (x, y, z, 2:3)
-##
 ## @end group
 ## @end example
 ##
@@ -66,3 +65,7 @@
   endif
 
 endfunction
+
+%!demo
+%! [x, y, z] = peaks ();
+%! contour (x, y, z);
--- a/scripts/plot/contour3.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/contour3.m	Tue Dec 04 03:03:55 2007 +0000
@@ -67,3 +67,10 @@
   endif
 
 endfunction
+
+%!demo
+%! contour3 (peaks (19));
+%! hold on
+%! surface (peaks (19), 'FaceColor', 'none', 'EdgeColor', 'black')
+%! colormap hot
+%! hold off
--- a/scripts/plot/contourc.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/contourc.m	Tue Dec 04 03:03:55 2007 +0000
@@ -113,3 +113,9 @@
   endif
 
 endfunction
+
+%!demo
+%! x = 0:2;
+%! y = x;
+%! z = x' * y;
+%! contourc (x, y, z, 2:3)
--- a/scripts/plot/contourf.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/contourf.m	Tue Dec 04 03:03:55 2007 +0000
@@ -254,3 +254,7 @@
   endif
 
 endfunction
+
+%!demo
+%! [x, y, z] = peaks (50);
+%! contourf (x, y, z, -7:9)
--- a/scripts/plot/cylinder.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/cylinder.m	Tue Dec 04 03:03:55 2007 +0000
@@ -81,3 +81,8 @@
   endif
 
 endfunction
+
+%!demo
+%! disp ("plotting a cone")
+%! [x, y, z] = cylinder (10:-1:0,50);
+%! surf (x, y, z);
--- a/scripts/plot/fplot.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/fplot.m	Tue Dec 04 03:03:55 2007 +0000
@@ -116,3 +116,9 @@
     legend (nams{:});
   endif
 endfunction
+
+%!demo
+%! fplot ("cos", [0, 2*pi])
+
+%!demo
+%! fplot ("[cos(x), sin(x)]", [0, 2*pi])
--- a/scripts/plot/plot3.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/plot3.m	Tue Dec 04 03:03:55 2007 +0000
@@ -301,3 +301,8 @@
   endif
 
 endfunction
+
+%!demo
+%! z = [0:0.05:5];
+%! plot3 (cos(2*pi*z), sin(2*pi*z), z, ";helix;");
+%! plot3 (z, exp(2i*pi*z), ";complex sinusoid;");
--- a/scripts/plot/plotyy.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/plotyy.m	Tue Dec 04 03:03:55 2007 +0000
@@ -126,3 +126,12 @@
     color = [0, 0, 0];
   endif
 endfunction
+
+%!demo
+%! x = 0:0.1:2*pi; 
+%! y1 = sin (x);
+%! y2 = exp (x - 1);
+%! ax = plotyy (x, y1, x - 1, y2, @@plot, @@semilogy);
+%! xlabel ("X");
+%! ylabel (ax(1), "Axis 1");
+%! ylabel (ax(2), "Axis 2");
--- a/scripts/plot/quiver3.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/quiver3.m	Tue Dec 04 03:03:55 2007 +0000
@@ -90,3 +90,10 @@
 %! hold on; 
 %! mesh(x,y,z); 
 %! hold off;
+
+%!demo
+%! [x, y, z] = peaks (25);
+%! surf (x, y, z);
+%! hold on;
+%! [u, v, w] = surfnorm (x, y, z / 10);
+%! quiver3 (x, y, z, u, v, w);
--- a/scripts/plot/scatter.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/scatter.m	Tue Dec 04 03:03:55 2007 +0000
@@ -76,3 +76,8 @@
   endif
 
 endfunction
+
+%!demo
+%! x = randn (100, 1);
+%! y = randn (100, 1);
+%! scatter (x, y, [], sqrt(x.^2 + y.^2));
--- a/scripts/plot/scatter3.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/scatter3.m	Tue Dec 04 03:03:55 2007 +0000
@@ -79,3 +79,7 @@
   endif
 
 endfunction
+
+%!demo
+%! [x, y, z] = peaks (20);
+%! scatter3 (x(:), y(:), z(:), [], z(:));
--- a/scripts/plot/slice.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/slice.m	Tue Dec 04 03:03:55 2007 +0000
@@ -172,3 +172,11 @@
   endif
 
 endfunction
+
+%!demo
+%! [x, y, z] = meshgrid (linspace (-8, 8, 32));
+%! v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2));
+%! slice (x, y, z, v, [], 0, []);
+%! [xi, yi] = meshgrid (linspace (-7, 7));
+%! zi = xi + yi;
+%! slice (x, y, z, v, xi, yi, zi);
--- a/scripts/plot/sombrero.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/sombrero.m	Tue Dec 04 03:03:55 2007 +0000
@@ -60,3 +60,6 @@
   endif
 
 endfunction
+
+%!demo
+%! sombrero ();
--- a/scripts/plot/stairs.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/stairs.m	Tue Dec 04 03:03:55 2007 +0000
@@ -115,3 +115,14 @@
   endif
 
 endfunction
+
+%!demo
+%! x = 1:10;
+%! y = rand (1, 10);
+## stairs (x, y);
+
+%!demo
+%! x = 1:10;
+%! y = rand (1, 10);
+%! [xs, ys] = stairs (x, y);
+%! plot (xs, ys);
--- a/scripts/plot/stem.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/stem.m	Tue Dec 04 03:03:55 2007 +0000
@@ -105,3 +105,32 @@
   endif
 
 endfunction
+
+%!demo
+%! x = 1:10;
+%! stem (x);
+
+%!demo
+%! x = 1:10;
+%! y = ones (1, length (x))*2.*x;
+%! stem (x, y);
+
+%!demo
+%! x = 1:10;
+%! y = ones (size (x))*2.*x;
+%! h = stem (x, y, "b");
+
+%!demo
+%! x = 1:10;
+%! y = ones (size (x))*2.*x;
+%! h = stem (x, y, "-.k");
+
+%!demo
+%! x = 1:10;
+%! y = ones (size (x))*2.*x;
+%! h = stem (x, y, "-.k.");
+
+%!demo
+%! x = 1:10;
+%! y = ones (size (x))*2.*x;
+%! h = stem (x, y, "fill");
--- a/scripts/plot/stem3.m	Tue Dec 04 02:27:27 2007 +0000
+++ b/scripts/plot/stem3.m	Tue Dec 04 03:03:55 2007 +0000
@@ -48,3 +48,7 @@
   endif
 
 endfunction
+
+%!demo
+%! theta = 0:0.2:6; 
+%! stem3 (cos (theta), sin (theta), theta)