Mercurial > hg > octave-terminal
changeset 14092:22c50cbad2ce stable
Add clf() to all plot demos.
* axis.m, compass.m, contour3.m, contourf.m, cylinder.m, ellipsoid.m,
errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m,
ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fplot.m,
loglogerr.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m,
quiver.m, quiver3.m, refreshdata.m, ribbon.m, rose.m, scatter3.m,
semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shading.m,
sombrero.m, stairs.m, stem.m, stem3.m, surf.m, surfc.m, surfl.m,
surfnorm.m, trimesh.m, triplot.m, trisurf.m, uimenu.m:
Add clf() to the beginning of each demo to ensure pre-existing graphics
objects don't interfere with the demo.
line wrap: on
line diff
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -506,6 +506,7 @@ %! axis tight %!demo +%! clf %! x = -10:0.1:10; %! y = sin(x)./(1+abs(x)) + x*0.1 - .4; %! plot (x, y) @@ -515,6 +516,7 @@ %! box off %!demo +%! clf %! x = -10:0.1:10; %! y = sin(x)./(1+abs(x)) + x*0.1 - .4; %! plot (x, y) @@ -524,6 +526,7 @@ %! box off %!demo +%! clf %! x = -10:0.1:10; %! y = sin(x)./(1+abs(x)) + x*0.1 - .4; %! plot (x, y) @@ -533,6 +536,7 @@ %! box off %!demo +%! clf %! x = -10:0.1:10; %! y = sin(x)./(1+abs(x)) + x*0.1 - .4; %! plot (x, y) @@ -542,6 +546,7 @@ %! box off %!demo +%! clf %! x = -10:0.1:10; %! y = sin(x)./(1+abs(x)) + x*0.1 - .4; %! plot (x, y)
--- a/scripts/plot/compass.m +++ b/scripts/plot/compass.m @@ -112,6 +112,7 @@ %!demo +%! clf %! randn_9x1_data = [-2.555884; 0.394974; -0.191871; -1.147024; 1.355425; -0.437335; -0.014370; -0.941312; 1.240300]; %! randn_1x9_data = [1.42934, -1.10821, -1.70404, 0.63357, -0.68337, -1.19771, -0.96502, -1.12810, 0.22457]; %! a = toeplitz ([1;randn_9x1_data], [1,randn_1x9_data]);
--- a/scripts/plot/contour3.m +++ b/scripts/plot/contour3.m @@ -75,6 +75,7 @@ endfunction %!demo +%! clf %! contour3 (peaks (19)); %! hold on %! surface (peaks (19), "facecolor", "none", "edgecolor", "black")
--- a/scripts/plot/contourf.m +++ b/scripts/plot/contourf.m @@ -81,10 +81,12 @@ endfunction %!demo +%! clf %! [x, y, z] = peaks (50); %! contourf (x, y, z, -7:9) %!demo +%! clf %! [theta, r] = meshgrid (linspace (0, 2*pi, 64), linspace(0,1,64)); %! [X, Y] = pol2cart (theta, r); %! Z = sin(2*theta).*(1-r);
--- a/scripts/plot/cylinder.m +++ b/scripts/plot/cylinder.m @@ -86,6 +86,7 @@ endfunction %!demo +%! clf %! [x, y, z] = cylinder (10:-1:0,50); %! surf (x, y, z); %! title ("a cone")
--- a/scripts/plot/ellipsoid.m +++ b/scripts/plot/ellipsoid.m @@ -70,4 +70,5 @@ endfunction %!demo +%! clf %! ellipsoid (0, 0, 1, 2, 3, 4, 20);
--- a/scripts/plot/errorbar.m +++ b/scripts/plot/errorbar.m @@ -138,16 +138,19 @@ %!demo +%! clf %! rand_1x11_data1 = [0.82712, 0.50325, 0.35613, 0.77089, 0.20474, 0.69160, 0.30858, 0.88225, 0.35187, 0.14168, 0.54270]; %! rand_1x11_data2 = [0.506375, 0.330106, 0.017982, 0.859270, 0.140641, 0.327839, 0.275886, 0.162453, 0.807592, 0.318509, 0.921112]; %! errorbar (0:10, rand_1x11_data1, 0.25*rand_1x11_data2); %!demo +%! clf %! rand_1x11_data3 = [0.423650, 0.142331, 0.213195, 0.129301, 0.975891, 0.012872, 0.635327, 0.338829, 0.764997, 0.401798, 0.551850]; %! rand_1x11_data4 = [0.682566, 0.456342, 0.132390, 0.341292, 0.108633, 0.601553, 0.040455, 0.146665, 0.309187, 0.586291, 0.540149]; %! errorbar(0:10, rand_1x11_data3, rand_1x11_data4, ">"); %!demo +%! clf %! x = 0:0.5:2*pi; %! err = x/100; %! y1 = sin (x); @@ -155,6 +158,7 @@ %! hg = errorbar (x, y1, err, "~", x, y2, err, ">"); %!demo +%! clf %! x = 0:0.5:2*pi; %! err = x/100; %! y1 = sin (x); @@ -162,6 +166,7 @@ %! hg = errorbar (x, y1, err, err, "#r", x, y2, err, err, "#~"); %!demo +%! clf %! x = 0:0.5:2*pi; %! err = x/100; %! y1 = sin (x);
--- a/scripts/plot/ezcontour.m +++ b/scripts/plot/ezcontour.m @@ -62,6 +62,7 @@ %!demo +%! clf %! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); %! ezcontour (f, [-3, 3]);
--- a/scripts/plot/ezcontourf.m +++ b/scripts/plot/ezcontourf.m @@ -62,5 +62,6 @@ %!demo +%! clf %! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); %! ezcontourf (f, [-3, 3]);
--- a/scripts/plot/ezmesh.m +++ b/scripts/plot/ezmesh.m @@ -83,10 +83,12 @@ %!demo +%! clf %! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); %! ezmesh (f, [-3, 3]); %!demo +%! clf %! fx = @(s,t) cos (s) .* cos(t); %! fy = @(s,t) sin (s) .* cos(t); %! fz = @(s,t) sin (t);
--- a/scripts/plot/ezmeshc.m +++ b/scripts/plot/ezmeshc.m @@ -73,6 +73,7 @@ %!demo +%! clf %! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); %! ezmeshc (f, [-3, 3]);
--- a/scripts/plot/ezplot.m +++ b/scripts/plot/ezplot.m @@ -81,11 +81,14 @@ %!demo +%! clf %! ezplot (@cos, @sin) %!demo +%! clf %! ezplot ("1/x") %!demo +%! clf %! ezplot (inline ("x^2 - y^2 = 1"))
--- a/scripts/plot/ezplot3.m +++ b/scripts/plot/ezplot3.m @@ -61,6 +61,7 @@ %!demo +%! clf %! fx = @(t) cos (t); %! fy = @(t) sin (t); %! fz = @(t) t;
--- a/scripts/plot/ezpolar.m +++ b/scripts/plot/ezpolar.m @@ -56,5 +56,6 @@ %!demo +%! clf %! ezpolar (@(t) 1 + sin (t));
--- a/scripts/plot/ezsurf.m +++ b/scripts/plot/ezsurf.m @@ -83,10 +83,12 @@ %!demo +%! clf %! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); %! ezsurf (f, [-3, 3]); %!demo +%! clf %! fx = @(s,t) cos (s) .* cos(t); %! fy = @(s,t) sin (s) .* cos(t); %! fz = @(s,t) sin (t);
--- a/scripts/plot/ezsurfc.m +++ b/scripts/plot/ezsurfc.m @@ -73,6 +73,7 @@ %!demo +%! clf %! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); %! ezsurfc (f, [-3, 3]);
--- a/scripts/plot/feather.m +++ b/scripts/plot/feather.m @@ -111,6 +111,7 @@ %!demo +%! clf %! phi = [0 : 15 : 360] * pi / 180; %! feather (sin (phi), cos (phi))
--- a/scripts/plot/fplot.m +++ b/scripts/plot/fplot.m @@ -128,7 +128,9 @@ endfunction %!demo +%! clf %! fplot ("cos", [0, 2*pi]) %!demo +%! clf %! fplot ("[cos(x), sin(x)]", [0, 2*pi])
--- a/scripts/plot/loglogerr.m +++ b/scripts/plot/loglogerr.m @@ -61,6 +61,7 @@ endfunction %!demo +%! clf %! x = exp (log(0.01):0.2:log(10)); %! y = wblpdf (x, 3, 2); %! eyu = 2*rand (size (y)) .* y;
--- a/scripts/plot/pcolor.m +++ b/scripts/plot/pcolor.m @@ -87,6 +87,7 @@ %! pcolor(Z); %!demo +%! clf %! [X,Y,Z]=sombrero; %! [Fx,Fy] = gradient(Z); %! pcolor(X,Y,Fx+Fy);
--- a/scripts/plot/pie.m +++ b/scripts/plot/pie.m @@ -68,15 +68,18 @@ %!demo +%! clf %! pie ([3, 2, 1], [0, 0, 1]); %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %!demo +%! clf %! pie ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"}); %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %! axis ([-2,2,-2,2]); %!demo +%! clf %! pie ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"}); %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %! axis ([-2,2,-2,2]);
--- a/scripts/plot/pie3.m +++ b/scripts/plot/pie3.m @@ -69,15 +69,18 @@ %!demo +%! clf %! pie3 ([5:-1:1], [0, 0, 1, 0, 0]); %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %!demo +%! clf %! pie3 ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"}); %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %! axis ([-2,2,-2,2]); %!demo +%! clf %! pie3 ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"}); %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %! axis ([-2,2,-2,2]);
--- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -333,6 +333,7 @@ endfunction %!demo +%! clf %! 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/plotmatrix.m +++ b/scripts/plot/plotmatrix.m @@ -96,6 +96,7 @@ endfunction %!demo +%! clf %! plotmatrix (randn (100, 3), 'g+') function plotmatrixdelete (h, d, ax)
--- a/scripts/plot/quiver.m +++ b/scripts/plot/quiver.m @@ -89,6 +89,7 @@ %! set (h, "maxheadsize", 0.33); %!demo +%! clf %! axis ("equal"); %! x = linspace (0,3,80); %! y = sin (2*pi*x);
--- a/scripts/plot/quiver3.m +++ b/scripts/plot/quiver3.m @@ -106,5 +106,13 @@ %! hold off; %!demo +%! clf +%! [x, y, z] = peaks (25); +%! surf (x, y, z); +%! hold on; +%! [u, v, w] = surfnorm (x, y, z / 10); +%! h = quiver3 (x, y, z, u, v, w); +%! set (h, "maxheadsize", 0.33); +%! hold off; %! shading interp
--- a/scripts/plot/refreshdata.m +++ b/scripts/plot/refreshdata.m @@ -106,6 +106,7 @@ endfunction %!demo +%! clf %! x = 0:0.1:10; %! y = sin (x); %! plot (x, y, "ydatasource", "y");
--- a/scripts/plot/ribbon.m +++ b/scripts/plot/ribbon.m @@ -88,6 +88,7 @@ %!demo +%! clf %! [x, y, z] = sombrero (); %! [x, y] = meshgrid (x, y); %! ribbon (y, z);
--- a/scripts/plot/rose.m +++ b/scripts/plot/rose.m @@ -106,5 +106,6 @@ %!demo +%! clf %! rose ([2*randn(1e5, 1), pi + 2*randn(1e5, 1)]);
--- a/scripts/plot/scatter3.m +++ b/scripts/plot/scatter3.m @@ -84,22 +84,26 @@ %!demo +%! clf %! [x, y, z] = peaks (20); %! scatter3 (x(:), y(:), z(:), [], z(:)); %!demo +%! clf %! x = rand (20,1); %! y = rand (20,1); %! z = rand (20,1); %! scatter3 (x(:), y(:), z(:), 10, z(:), "s"); %!demo +%! clf %! x = rand (20,1); %! y = rand (20,1); %! z = rand (20,1); %! scatter3 (x(:), y(:), z(:), 20*z(:), z(:), "s"); %!demo +%! clf %! x = rand (20,1); %! y = rand (20,1); %! z = rand (20,1);
--- a/scripts/plot/semilogx.m +++ b/scripts/plot/semilogx.m @@ -64,6 +64,7 @@ %!demo +%! clf (); %! x = 1:0.01:10; %! y = (x .* (1 + rand (size (x)))) .^ 2; %! semilogx (y, x);
--- a/scripts/plot/semilogxerr.m +++ b/scripts/plot/semilogxerr.m @@ -61,6 +61,7 @@ endfunction %!demo +%! clf %! x = exp (log(0.01):0.2:log(10)); %! y = wblpdf (x, 2, 2); %! ey = 0.5*rand (size (y)) .* y;
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -64,6 +64,7 @@ endfunction %!demo +%! clf (); %! x = 1:0.01:10; %! y = (x .* (1 + rand (size (x)))) .^ 2; %! semilogy (x, y);
--- a/scripts/plot/semilogyerr.m +++ b/scripts/plot/semilogyerr.m @@ -61,6 +61,7 @@ endfunction %!demo +%! clf %! x = 0.25:0.25:10; %! y = wblpdf (x, 4, 2); %! eyu = rand (size (y));
--- a/scripts/plot/shading.m +++ b/scripts/plot/shading.m @@ -82,26 +82,31 @@ %! title ('shading "faceted"') %!demo +%! clf %! sombrero %! shading flat %! title ('shading "flat"') %!demo +%! clf %! sombrero %! shading interp %! title ('shading "interp"') %!demo +%! clf %! pcolor (peaks ()) %! shading faceted %! title ('shading "faceted"') %!demo +%! clf %! pcolor (peaks ()) %! shading flat %! title ('shading "flat"') %!demo +%! clf %! pcolor (peaks ()) %! shading interp %! title ('shading "interp"')
--- a/scripts/plot/sombrero.m +++ b/scripts/plot/sombrero.m @@ -62,4 +62,5 @@ endfunction %!demo +%! clf %! sombrero ();
--- a/scripts/plot/stairs.m +++ b/scripts/plot/stairs.m @@ -210,12 +210,14 @@ %!demo +%! clf %! x = 1:10; %! rand_1x10_data1 = [0.073, 0.455, 0.837, 0.124, 0.426, 0.781, 0.004, 0.024, 0.519, 0.698]; %! y = rand_1x10_data1; %! stairs (x, y); %!demo +%! clf %! x = 1:10; %! rand_1x10_data2 = [0.014, 0.460, 0.622, 0.394, 0.531, 0.378, 0.466, 0.788, 0.342, 0.893]; %! y = rand_1x10_data2; @@ -223,9 +225,11 @@ %! plot (xs, ys); %!demo +%! clf %! stairs (1:9); %!demo +%! clf %! [xs, ys] = stairs (9:-1:1); %! plot (xs, ys);
--- a/scripts/plot/stem.m +++ b/scripts/plot/stem.m @@ -88,35 +88,42 @@ %!demo +%! clf %! x = 1:10; %! stem (x); %!demo +%! clf %! x = 1:10; %! y = 2*x; %! stem (x, y); %!demo +%! clf %! x = 1:10; %! y = 2*x; %! h = stem (x, y, "r"); %!demo +%! clf %! x = 1:10; %! y = 2*x; %! h = stem (x, y, "-.k"); %!demo +%! clf %! x = 1:10; %! y = 2*x; %! h = stem (x, y, "-.k."); %!demo +%! clf %! x = 1:10; %! y = 2*x; %! h = stem (x, y, "filled"); %!demo +%! clf %! x = [0 : 10]'; %! y = [sin(x), cos(x)]; %! h = stem (x, y);
--- a/scripts/plot/stem3.m +++ b/scripts/plot/stem3.m @@ -53,5 +53,6 @@ endfunction %!demo +%! clf %! theta = 0:0.2:6; %! stem3 (cos (theta), sin (theta), theta)
--- a/scripts/plot/surf.m +++ b/scripts/plot/surf.m @@ -71,12 +71,14 @@ %! surf (Z); %!demo +%! clf %! [~,~,Z] = sombrero; %! [Fx,Fy] = gradient (Z); %! surf (Z, Fx+Fy); %! shading interp; %!demo +%! clf %! [X,Y,Z] = sombrero; %! [~,Fy] = gradient (Z); %! surf (X, Y, Z, Fy);
--- a/scripts/plot/surfc.m +++ b/scripts/plot/surfc.m @@ -80,12 +80,14 @@ %! surfc(Z); %!demo +%! clf %! [~,~,Z]=sombrero; %! [Fx,Fy] = gradient(Z); %! surfc(Z,Fx+Fy); %! shading interp; %!demo +%! clf %! [X,Y,Z]=sombrero; %! [~,Fy] = gradient(Z); %! surfc(X,Y,Z,Fy);
--- a/scripts/plot/surfl.m +++ b/scripts/plot/surfl.m @@ -179,6 +179,7 @@ %! shading interp; %!demo +%! clf %! [X,Y,Z]=sombrero; %! colormap(copper); %! [az, el] = view;
--- a/scripts/plot/surfnorm.m +++ b/scripts/plot/surfnorm.m @@ -142,13 +142,16 @@ endfunction %!demo +%! clf %! colormap (jet (64)) %! [x, y, z] = peaks(10); %! surfnorm (x, y, z); %!demo +%! clf %! surfnorm (peaks(10)); %!demo +%! clf %! surfnorm (peaks(32)); %! shading interp
--- a/scripts/plot/trimesh.m +++ b/scripts/plot/trimesh.m @@ -56,6 +56,7 @@ %!demo +%! clf %! old_state = rand ("state"); %! restore_state = onCleanup (@() rand ("state", old_state)); %! rand ("state", 10);
--- a/scripts/plot/triplot.m +++ b/scripts/plot/triplot.m @@ -48,6 +48,7 @@ %!demo +%! clf %! old_state = rand ("state"); %! restore_state = onCleanup (@() rand ("state", old_state)); %! rand ("state", 2);
--- a/scripts/plot/trisurf.m +++ b/scripts/plot/trisurf.m @@ -73,6 +73,7 @@ %!demo +%! clf %! old_state = rand ("state"); %! restore_state = onCleanup (@() rand ("state", old_state)); %! rand ("state", 10); @@ -84,6 +85,7 @@ %! trisurf (tri, x(:), y(:), z(:)); %!demo +%! clf %! x = rand (100, 1); %! y = rand (100, 1); %! z = x.^2 + y.^2; @@ -91,6 +93,7 @@ %! trisurf (tri, x, y, z); %!demo +%! clf %! x = rand (100, 1); %! y = rand (100, 1); %! z = x.^2 + y.^2; @@ -98,6 +101,7 @@ %! trisurf (tri, x, y, z, "facecolor", "interp"); %!demo +%! clf %! x = rand (100, 1); %! y = rand (100, 1); %! z = x.^2 + y.^2;