changeset 16828:ddac88d32d6a

Make demos in plot m-files compatible with Matlab for running comparison script. * scripts/plot/isosurface.m, scripts/plot/line.m, scripts/plot/mesh.m, scripts/plot/plotyy.m, scripts/plot/printd.m, scripts/plot/semilogy.m, scripts/plot/shrinkfaces.m, scripts/plot/stairs.m, scripts/plot/stem.m, scripts/plot/stemleaf.m, scripts/plot/tetramesh.m: Replace double quote (") with single quote ('). Use '%' for comment character. Use '...' for line continuation.
author Rik <rik@octave.org>
date Sun, 23 Jun 2013 14:47:05 -0700
parents ac5313d94f20
children f2e09c9bcb7a
files scripts/plot/isosurface.m scripts/plot/line.m scripts/plot/mesh.m scripts/plot/plotyy.m scripts/plot/printd.m scripts/plot/semilogy.m scripts/plot/shrinkfaces.m scripts/plot/stairs.m scripts/plot/stem.m scripts/plot/stemleaf.m scripts/plot/tetramesh.m
diffstat 11 files changed, 105 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/isosurface.m
+++ b/scripts/plot/isosurface.m
@@ -197,9 +197,9 @@
 %! isosurface (x, y, z, v, 1);
 
 %!shared x, y, z, val
-%! [x, y, z]  = meshgrid (0:1, 0:1, 0:1); %% Points for single
-%! val        = [0, 0; 0, 0];             %% cube and a 3-D
-%! val(:,:,2) = [0, 0; 1, 0];             %% array of values
+%! [x, y, z]  = meshgrid (0:1, 0:1, 0:1); # Points for single
+%! val        = [0, 0; 0, 0];             # cube and a 3-D
+%! val(:,:,2) = [0, 0; 1, 0];             # array of values
 %!test
 %! fv = isosurface (x, y, z, val, 0.3);
 %! assert (isfield (fv, "vertices"), true);
--- a/scripts/plot/line.m
+++ b/scripts/plot/line.m
@@ -43,20 +43,21 @@
 
 endfunction
 
+
 %!demo
 %! clf
 %! x = 0:0.3:10;
 %! y1 = cos (x);
 %! y2 = sin (x);
 %! subplot (3,1,1);
-%! args = {"color", "b", "marker", "s"};
-%! line ([x(:), x(:)], [y1(:), y2(:)], args{:})
-%! title ("Test broadcasting for line()")
+%!  args = {'color', 'b', 'marker', 's'};
+%!  line ([x(:), x(:)], [y1(:), y2(:)], args{:});
+%!  title ('Test broadcasting for line()');
 %! subplot (3,1,2);
-%! line (x(:), [y1(:), y2(:)], args{:})
+%!  line (x(:), [y1(:), y2(:)], args{:});
 %! subplot (3,1,3);
-%! line ([x(:), x(:)+pi/2], y1(:), args{:})
-%! xlim ([0 10])
+%!  line ([x(:), x(:)+pi/2], y1(:), args{:});
+%!  xlim ([0 10]);
 
 %!test
 %! hf = figure ("visible", "off");
--- a/scripts/plot/mesh.m
+++ b/scripts/plot/mesh.m
@@ -64,24 +64,24 @@
 
 
 %!demo
-%! clf ();
+%! clf;
 %! x = logspace (0,1,11);
 %! z = x'*x;
 %! mesh (x, x, z, z.^2);
-%! xlabel xlabel
-%! ylabel ylabel
-%! zlabel "linear scale"
+%! xlabel xlabel;
+%! ylabel ylabel;
+%! zlabel 'linear scale';
 
 %!demo
-%! clf ();
+%! clf;
 %! x = logspace (0,1,11);
 %! z = x'*x;
 %! mesh (x, x, z, z.^2);
-%! set (gca, "zscale", "log")
-%! xlabel xlabel
-%! ylabel ylabel
-%! zlabel "log scale"
-%! if (strcmp (get (gcf, "__graphics_toolkit__"), "gnuplot"))
-%!   title ({"Gnuplot: mesh color is wrong", "This a Gnuplot bug"})
+%! set (gca, 'zscale', 'log');
+%! xlabel xlabel;
+%! ylabel ylabel;
+%! zlabel 'log scale';
+%! if (strcmp (get (gcf, '__graphics_toolkit__'), 'gnuplot'))
+%!   title ({'Gnuplot: mesh color is wrong', 'This a Gnuplot bug'});
 %! endif
 
--- a/scripts/plot/plotyy.m
+++ b/scripts/plot/plotyy.m
@@ -277,11 +277,11 @@
 %! y = 5 * cos (t);
 %! [hax, h1, h2] = plotyy (t, x, t, y);
 %! [~, h3, h4] = plotyy (t+1, x, t+1, y);
-%! set ([h3, h4], "linestyle", "--")
-%! xlabel (hax(1), 'xlabel')
-%! title (hax(2), 'title')
-%! ylabel (hax(1), 'Left axis is Blue')
-%! ylabel (hax(2), 'Right axis is Green')
+%! set ([h3, h4], 'linestyle', '--');
+%! xlabel (hax(1), 'xlabel');
+%! title (hax(2), 'title');
+%! ylabel (hax(1), 'Left axis is Blue');
+%! ylabel (hax(2), 'Right axis is Green');
 
 function deleteplotyy (h, d, ax2, t2)
   if (ishandle (ax2) && strcmp (get (ax2, "type"), "axes")
--- a/scripts/plot/printd.m
+++ b/scripts/plot/printd.m
@@ -84,18 +84,19 @@
   pr_out =  sprintf ("%s file %s written\n", opt, filename);
 endfunction
 
+
 %!demo
 %! r2 = char (
-%! "stem step: 10, data: unsorted.",
-%! "Hinges:    lo: 12, hi: 42"     ,
-%! "   1 | 22118"                  ,
-%! "   2 | 28"                     ,
-%! "   3 | 98"                     ,
-%! "   4 | 244"                    ,
-%! "   5 | 2"                      );
-%! printd (r2, "test_p.txt");
-%! system ("cat test_p.txt");
-%! delete ("test_p.txt");
+%! 'stem step: 10, data: unsorted.',
+%! 'Hinges:    lo: 12, hi: 42'     ,
+%! '   1 | 22118'                  ,
+%! '   2 | 28'                     ,
+%! '   3 | 98'                     ,
+%! '   4 | 244'                    ,
+%! '   5 | 2'                      );
+%! printd (r2, 'test_p.txt');
+%! system ('cat test_p.txt');
+%! delete ('test_p.txt');
 
 %!test
 %! r2 = char (
@@ -110,6 +111,5 @@
 %! r4 = fileread ("test_p.txt");
 %! delete ("test_p.txt");
 %! r2 = disp (r2);
-%! assert (r4, r2)
+%! assert (r4, r2);
 
-
--- a/scripts/plot/semilogy.m
+++ b/scripts/plot/semilogy.m
@@ -76,12 +76,12 @@
 %! y = logspace (-5, 1, 10);
 %!
 %! subplot (2,1,1);
-%! semilogy (x, y);
-%! ylabel ('semilogy (x, y)');
+%!  semilogy (x, y);
+%!  ylabel ('semilogy (x, y)');
 %!
 %! subplot (2,1,2);
-%! semilogy (x, -y);
-%! ylabel ('semilogy (x, -y)');
+%!  semilogy (x, -y);
+%!  ylabel ('semilogy (x, -y)');
 
 %!demo
 %! clf;
@@ -89,14 +89,14 @@
 %! y = logspace (-5, 1, 10);
 %!
 %! subplot (2,1,1);
-%! semilogy (x, y);
-%! set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition');
-%! ylabel ({'semilogy (x, y)', 'ydir = reversed'});
+%!  semilogy (x, y);
+%!  set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition');
+%!  ylabel ({'semilogy (x, y)', 'ydir = reversed'});
 %!
 %! subplot (2,1,2);
-%! semilogy (x, -y);
-%! set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition');
-%! ylabel ({'semilogy (x, -y)', 'ydir = reversed'});
+%!  semilogy (x, -y);
+%!  set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition');
+%!  ylabel ({'semilogy (x, -y)', 'ydir = reversed'});
 
 %!test
 %! hf = figure ("visible", "off");
--- a/scripts/plot/shrinkfaces.m
+++ b/scripts/plot/shrinkfaces.m
@@ -149,59 +149,60 @@
 
 endfunction
 
+
 %!demo
+%! clf;
 %! faces = [1 2 3; 1 3 4];
 %! vertices = [0 0; 1 0; 1 1; 0 1];
-%! clf ()
-%! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none")
+%! patch ('Faces', faces, 'Vertices', vertices, 'FaceColor', 'none');
 %! fv = shrinkfaces (faces, vertices, 0.25);
-%! patch (fv)
-%! axis equal
+%! patch (fv);
+%! axis equal;
 
 %!demo
+%! clf;
 %! faces = [1 2 3 4; 5 6 7 8];
 %! vertices = [0 0; 1 0; 2 1; 1 1; 2 0; 3 0; 4 1; 3.5 1];
-%! clf ()
-%! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none")
+%! patch ('Faces', faces, 'Vertices', vertices, 'FaceColor', 'none');
 %! fv = shrinkfaces (faces, vertices, 0.25);
-%! patch (fv)
-%! axis equal
-%! grid on
+%! patch (fv);
+%! axis equal;
+%! grid on;
 
 %!demo
+%! clf;
 %! faces = [1 2 3 4];
 %! vertices = [-1 2; 0 0; 1 2; 0 1];
-%! clf ()
-%! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none")
+%! patch ('Faces', faces, 'Vertices', vertices, 'FaceColor', 'none');
 %! fv = shrinkfaces (faces, vertices, 0.25);
-%! patch (fv)
-%! axis equal
-%! grid on
-%! title "faces which are not convex are clearly not allowed"
+%! patch (fv);
+%! axis equal;
+%! grid on;
+%! title 'faces which are not convex are clearly not allowed'
 
 %!demo
+%! clf;
 %! [phi r] = meshgrid (linspace (0, 1.5*pi, 16), linspace (1, 2, 4));
 %! tri = delaunay (phi(:), r(:));
 %! v = [r(:).*sin(phi(:)) r(:).*cos(phi(:))];
-%! clf ()
-%! p = patch ("Faces", tri, "Vertices", v, "FaceColor", "none");
+%! p = patch ('Faces', tri, 'Vertices', v, 'FaceColor', 'none');
 %! fv = shrinkfaces (p);
-%! patch (fv)
-%! axis equal
-%! grid on
+%! patch (fv);
+%! axis equal;
+%! grid on;
 
 %!demo
-%! N = 10; # N intervals per axis
+%! clf;
+%! N = 10;  % N intervals per axis
 %! [x, y, z] = meshgrid (linspace (-4,4,N+1));
 %! val = x.^3 + y.^3 + z.^3;
 %! fv = isosurface (x, y, z, val, 3, z);
 %!
-%! clf ()
-%! p = patch ("Faces", fv.faces, "Vertices", fv.vertices, "FaceVertexCData", ...
-%!            fv.facevertexcdata, "FaceColor", "interp", "EdgeColor", "black");
-%! axis equal
-%! view (115, 30)
-%! drawnow
+%! p = patch ('Faces', fv.faces, 'Vertices', fv.vertices, 'FaceVertexCData', ...
+%!            fv.facevertexcdata, 'FaceColor', 'interp', 'EdgeColor', 'black');
+%! axis equal;
+%! view (115, 30);
+%! drawnow;
 %! shrinkfaces (p, 0.6);
 
 %!shared faces, vertices, nfv, nfv2
@@ -209,8 +210,9 @@
 %! vertices = [0 0 0; 1 0 0; 1 1 0];
 %! nfv = shrinkfaces (faces, vertices, 0.7);
 %! nfv2 = shrinkfaces (nfv, 1/0.7);
-%!assert (isfield (nfv, "faces"));
-%!assert (isfield (nfv, "vertices"));
-%!assert (size (nfv.faces), [1 3]);
-%!assert (size (nfv.vertices), [3 3]);
-%!assert (norm (nfv2.vertices - vertices), 0, 2*eps);
+%!assert (isfield (nfv, "faces"))
+%!assert (isfield (nfv, "vertices"))
+%!assert (size (nfv.faces), [1 3])
+%!assert (size (nfv.vertices), [3 3])
+%!assert (norm (nfv2.vertices - vertices), 0, 2*eps)
+
--- a/scripts/plot/stairs.m
+++ b/scripts/plot/stairs.m
@@ -240,7 +240,7 @@
 %! hs = stairs (x(1), y(1));
 %! set (gca (), 'xlim', [1, N-1], 'ylim', [0, 1]);
 %! for k=2:N
-%!   set (hs, 'xdata', x(1:k), 'ydata', y(1:k))
+%!   set (hs, 'xdata', x(1:k), 'ydata', y(1:k));
 %!   drawnow ();
 %!   pause (0.2);
 %! end
--- a/scripts/plot/stem.m
+++ b/scripts/plot/stem.m
@@ -142,3 +142,4 @@
 %!   drawnow ();
 %!   pause (0.2);
 %! end
+
--- a/scripts/plot/stemleaf.m
+++ b/scripts/plot/stemleaf.m
@@ -306,30 +306,31 @@
 
 
 %!demo
-%! ## Unsorted plot:
+%! %% Unsorted plot:
 %! x = [-22 12 -28 52  39 -2 12 10 11 11 42 38 44 18 44];
-%! stemleaf (x, "Unsorted plot");
+%! stemleaf (x, 'Unsorted plot');
 
 %!demo
-%! ## Sorted leaves:
+%! %% Sorted leaves:
 %! x = [-22 12 -28 52  39 -2 12 10 11 11 42 38 44 18 44];
 %! y = sort (x);
-%! stemleaf (y, "Sorted leaves");
+%! stemleaf (y, 'Sorted leaves');
 
 %!demo
-%! ## Sorted leaves (large dataset):
-%! x = [-22 12 -28 52  39 -2 12 10 11 11 42 38 44 18 44 37 113 124 37 48 127  \
-%!      36 29 31 125 139 131 115 105 132 104 123 35 113 122 42 117 119 58 109 \
-%!      23 105 63 27 44 105 99 41 128 121 116 125 32 61 37 127 29 113 121 58  \
-%!      114 126 53 114 96 25 109 7 31 141 46 -13 71 43 117 116 27 7 68 40 31  \
-%!      115 124 42 128 52 71 118 117 38 27 106 33 117 116 111 40 119 47 105 57\
-%!      122 109 124 115 43 120 43 27 27 18 28 48 125 107 114 34 133 45 120 30 \
-%!      127 31 116 146 21 23 30 10 20 21 30 0 100 110 1 20 0];
+%! %% Sorted leaves (large dataset):
+%! x = [-22 12 -28 52  39 -2 12 10 11 11 42 38 44 18 44 37 113 124 37 48     ...
+%!      127 36 29 31 125 139 131 115 105 132 104 123 35 113 122 42 117 119   ...
+%!      58 109 23 105 63 27 44 105 99 41 128 121 116 125 32 61 37 127 29 113 ...
+%!      121 58 114 126 53 114 96 25 109 7 31 141 46 -13 71 43 117 116 27 7   ...
+%!      68 40 31 115 124 42 128 52 71 118 117 38 27 106 33 117 116 111 40    ...
+%!      119 47 105 57 122 109 124 115 43 120 43 27 27 18 28 48 125 107 114   ...
+%!      34 133 45 120 30 127 31 116 146 21 23 30 10 20 21 30 0 100 110 1 20  ...
+%!      0];
 %! y = sort (x);
-%! stemleaf (y, "Sorted leaves (large dataset)");
+%! stemleaf (y, 'Sorted leaves (large dataset)');
 
 %!demo
-%! ## Gaussian leaves:
+%! %% Gaussian leaves:
 %! x = fix (30 * randn (300,1));
 %! stemleaf (x);
 
@@ -544,7 +545,8 @@
 
 %!test
 %! ##   Example from EDA: Chevrolet Prices pg. 30
-%! x = [150 250 688 695 795 795 895 895 895 1099 1166 1333 1499 1693 1699 1775 1995];
+%! x = [150 250 688 695 795 795 895 895 895 ...
+%!      1099 1166 1333 1499 1693 1699 1775 1995];
 %! rexp = char (
 %! "       Data: Chevrolet Prices EDA pg.30",
 %! " "                                      ,
--- a/scripts/plot/tetramesh.m
+++ b/scripts/plot/tetramesh.m
@@ -126,10 +126,10 @@
 %! X = [x(:) y(:) z(:)];
 %! colormap (jet (64));
 %! h = tetramesh (tetra, X);
-%! set (h(1:2:end), "Visible", "off");
+%! set (h(1:2:end), 'Visible', 'off');
 %! axis equal;
 %! view (30, 20);
-%! title ("Using jet (64), every other tetrahedron invisible");
+%! title ('Using jet (64), every other tetrahedron invisible');
 
 %!demo
 %! clf;
@@ -141,8 +141,8 @@
 %! tetra = delaunay3 (x, y, z);
 %! X = [x(:) y(:) z(:)];
 %! colormap (gray (256));
-%! tetramesh (tetra, X, 21:20:241, "EdgeColor", "w");
+%! tetramesh (tetra, X, 21:20:241, 'EdgeColor', 'w');
 %! axis equal;
 %! view (30, 20);
-%! title ("Using gray (256) and white edges");
+%! title ('Using gray (256) and white edges');