Mercurial > hg > octave-lyh
changeset 17198:df4c4b7708a4
Add titles and clean-up plotting %!demos.
* scripts/plot/area.m, scripts/plot/axis.m, scripts/plot/bar.m,
scripts/plot/barh.m, scripts/plot/clabel.m, scripts/plot/colorbar.m,
scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/contour.m,
scripts/plot/contour3.m, scripts/plot/contourf.m, scripts/plot/cylinder.m,
scripts/plot/ellipsoid.m, scripts/plot/errorbar.m, scripts/plot/ezplot.m,
scripts/plot/ezplot3.m, scripts/plot/ezpolar.m, scripts/plot/feather.m,
scripts/plot/fplot.m, scripts/plot/hold.m, scripts/plot/isosurface.m,
scripts/plot/legend.m, scripts/plot/loglog.m, scripts/plot/loglogerr.m,
scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m,
scripts/plot/patch.m, scripts/plot/pcolor.m, scripts/plot/pie.m,
scripts/plot/pie3.m, scripts/plot/plot.m, scripts/plot/plot3.m,
scripts/plot/polar.m, scripts/plot/rectangle.m, scripts/plot/ribbon.m,
scripts/plot/rose.m, scripts/plot/scatter.m, scripts/plot/scatter3.m,
scripts/plot/semilogx.m, scripts/plot/semilogxerr.m, scripts/plot/semilogy.m,
scripts/plot/semilogyerr.m, scripts/plot/sombrero.m, scripts/plot/stem3.m,
scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfl.m,
scripts/plot/title.m, scripts/plot/waterfall.m: Add titles and clean-up
plotting %!demos.
line wrap: on
line diff
--- a/scripts/plot/area.m +++ b/scripts/plot/area.m @@ -233,6 +233,7 @@ %! area (t, y); %! axis tight %! legend ('sin^2', 'cos^2', 'location', 'NorthEastOutside'); +%! title ('area() plot'); %!demo %! # Show effects of setting BaseValue @@ -248,7 +249,9 @@ %! title ({'Parabola y = x^2 -1';'BaseValue = -1'}); %!demo +%! clf; %! x = 0:10; %! y = rand (size (x)); %! h = area (x, y); %! set (h, 'ydata', sort (get (h, 'ydata'))) +%! title ('area() plot of sorted data');
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -538,20 +538,20 @@ %! x = -10:0.1:10; %! y = sin (x)./(1 + abs (x)) + 0.1*x - 0.4; %! plot (x, y); -%! title ('no plot box'); %! set (gca, 'xaxislocation', 'zero'); %! set (gca, 'yaxislocation', 'zero'); %! box off; +%! title ({'no plot box', 'xaxislocation = zero, yaxislocation = zero'}); %!demo %! clf; %! x = -10:0.1:10; %! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4; %! plot (x, y); -%! title ('no plot box'); %! set (gca, 'xaxislocation', 'zero'); %! set (gca, 'yaxislocation', 'left'); %! box off; +%! title ({'no plot box', 'xaxislocation = zero, yaxislocation = left'}); %!demo %! clf; @@ -562,26 +562,27 @@ %! set (gca, 'xaxislocation', 'zero'); %! set (gca, 'yaxislocation', 'right'); %! box off; +%! title ({'no plot box', 'xaxislocation = zero, yaxislocation = right'}); %!demo %! clf; %! x = -10:0.1:10; %! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4; %! plot (x, y); -%! title ('no plot box'); %! set (gca, 'xaxislocation', 'bottom'); %! set (gca, 'yaxislocation', 'zero'); %! box off; +%! title ({'no plot box', 'xaxislocation = bottom, yaxislocation = zero'}); %!demo %! clf; %! x = -10:0.1:10; %! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4; %! plot (x, y); -%! title ('no plot box'); %! set (gca, 'xaxislocation', 'top'); %! set (gca, 'yaxislocation', 'zero'); %! box off; +%! title ({'no plot box', 'xaxislocation = top, yaxislocation = zero'}); %!test %! hf = figure ("visible", "off");
--- a/scripts/plot/bar.m +++ b/scripts/plot/bar.m @@ -107,6 +107,7 @@ %! y = rand (11, 1); %! h = bar (y); %! set (h, 'ydata', sort (rand (11, 1))); +%! title ('bar() graph') %!demo %! clf; @@ -114,4 +115,5 @@ %! set (h(1), 'facecolor', 'r') %! set (h(2), 'facecolor', 'g') %! set (h(3), 'facecolor', 'b') +%! title ('bar() graph w/multiple bars')
--- a/scripts/plot/barh.m +++ b/scripts/plot/barh.m @@ -63,6 +63,7 @@ %! clf; %! x = rand (10, 1); %! barh (x); +%! title ('barh() graph') %!demo %! clf; @@ -70,4 +71,5 @@ %! set (h(1), 'facecolor', 'r') %! set (h(2), 'facecolor', 'g') %! set (h(3), 'facecolor', 'b') +%! title ('barh() graph w/multiple bars')
--- a/scripts/plot/clabel.m +++ b/scripts/plot/clabel.m @@ -142,10 +142,12 @@ %! colormap ('default'); %! [c, h] = contour (peaks (), -4:6); %! clabel (c, h, -4:2:6, 'fontsize', 12); +%! title ('clabel() labeling every other contour'); %!demo %! clf; %! colormap ('default'); %! [c, h] = contourf (peaks (), -7:6); %! clabel (c, h, -6:2:6, 'fontsize', 12); +%! title ('clabel() labeling every other contour');
--- a/scripts/plot/colorbar.m +++ b/scripts/plot/colorbar.m @@ -473,6 +473,7 @@ %! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); %! imagesc (x); %! colorbar (); +%! title ('colorbar() example'); %!demo %! clf;
--- a/scripts/plot/comet.m +++ b/scripts/plot/comet.m @@ -91,8 +91,11 @@ %!demo %! clf; +%! title ('comet() animation'); +%! hold on; %! t = 0:.1:2*pi; %! x = cos (2*t) .* (cos (t).^2); %! y = sin (2*t) .* (sin (t).^2); %! comet (x, y, 0.05); +%! hold off;
--- a/scripts/plot/comet3.m +++ b/scripts/plot/comet3.m @@ -92,6 +92,9 @@ %!demo %! clf; +%! title ('comet3() animation'); +%! view (3); hold on; %! t = 0:pi/20:5*pi; %! comet3 (cos (t), sin (t), t, 0.05); +%! hold off;
--- a/scripts/plot/contour.m +++ b/scripts/plot/contour.m @@ -87,6 +87,8 @@ %! colormap ('default'); %! [x, y, z] = peaks (); %! contour (x, y, z); +%! title ('contour() plot of peaks() function'); +%! title ({'contour() plot (isolines of constant Z)'; 'Z = peaks()'); %!demo %! clf; @@ -95,15 +97,7 @@ %! [X, Y] = pol2cart (theta, r); %! Z = sin (2*theta) .* (1-r); %! contour (X, Y, abs (Z), 10); - -%!demo -%! clf; -%! colormap ('default'); -%! x = linspace (-2, 2); -%! [x, y] = meshgrid (x); -%! z = sqrt (x.^2 + y.^2) ./ (x.^2 + y.^2 + 1); -%! contourf (x, y, z, [0.4, 0.4]); -%! title ('The hole should be filled with the background color'); +%! title ({'contour() plot'; 'polar fcn Z = sin (2*theta) * (1-r)'}); %!test %! hf = figure ("visible", "off");
--- a/scripts/plot/contour3.m +++ b/scripts/plot/contour3.m @@ -93,10 +93,12 @@ %! clf; %! contour3 (peaks (19)); %! hold on; -%! surface (peaks (19), 'facecolor', 'none', 'edgecolor', 'black'); +%! surf (peaks (19), 'facecolor', 'none', 'edgecolor', [0.8 0.8 0.8]); %! colormap (hot (64)); %! axis tight; %! zlim auto; %! box off; +%! view (315, 17); +%! title ('contour3 of peaks() function'); %! hold off;
--- a/scripts/plot/contourf.m +++ b/scripts/plot/contourf.m @@ -89,6 +89,7 @@ %! colormap ('default'); %! [x, y, z] = peaks (50); %! contourf (x, y, z, -7:9); +%! title ({'contourf() plot (filled contour lines)'; 'Z = peaks()'); %!demo %! clf; @@ -97,4 +98,14 @@ %! [X, Y] = pol2cart (theta, r); %! Z = sin (2*theta) .* (1-r); %! contourf (X, Y, abs (Z), 10); +%! title ({'contourf() plot'; 'polar fcn Z = sin (2*theta) * (1-r)'}); +%!demo +%! clf; +%! colormap ('default'); +%! x = linspace (-2, 2); +%! [x, y] = meshgrid (x); +%! z = sqrt (x.^2 + y.^2) ./ (x.^2 + y.^2 + 1); +%! contourf (x, y, z, [0.4, 0.4]); +%! title ('Hole should be filled with the background color'); +
--- a/scripts/plot/cylinder.m +++ b/scripts/plot/cylinder.m @@ -101,7 +101,7 @@ %!demo %! clf; %! colormap ('default'); -%! [x, y, z] = cylinder (10:-1:0,50); +%! [x, y, z] = cylinder (10:-1:0, 50); %! surf (x, y, z); -%! title ('a cone'); +%! title ('cylinder() with linearly shrinking radius produces a cone');
--- a/scripts/plot/ellipsoid.m +++ b/scripts/plot/ellipsoid.m @@ -92,4 +92,5 @@ %!demo %! clf; %! ellipsoid (0, 0, 1, 2, 3, 4, 20); +%! title ('ellipsoid()');
--- a/scripts/plot/errorbar.m +++ b/scripts/plot/errorbar.m @@ -153,12 +153,14 @@ %! 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); +%! title ('errorbar() with Y errorbars'); %!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, '>'); +%! title ('errorbar() with X errorbars'); %!demo %! clf; @@ -166,7 +168,10 @@ %! err = x/30; %! y1 = sin (x); %! y2 = cos (x); -%! hg = errorbar (x, y1, err, '~', x, y2, err, '>'); +%! errorbar (x, y1, err, '~', x, y2, err, '>'); +%! legend ("Y errbar", "X errbar"); +%! title ('errorbar() with 2 datasets'); + %!demo %! clf; @@ -174,7 +179,9 @@ %! err = x/30; %! y1 = sin (x); %! y2 = cos (x); -%! hg = errorbar (x, y1, err, err, '#r', x, y2, err, err, '#~'); +%! errorbar (x, y1, err, err, '#r', x, y2, err, err, '#~'); +%! legend ("X errbox", "Y errbox"); +%! title ('errorbar() with error boxes'); %!demo %! clf; @@ -182,6 +189,8 @@ %! err = x/30; %! y1 = sin (x); %! y2 = cos (x); -%! hg = errorbar (x, y1, err, err, err, err, '~>', ... -%! x, y2, err, err, err, err, '#~>-*'); +%! errorbar (x, y1, err, err, err, err, '~>', ... +%! x, y2, err, err, err, err, '#~>-*'); +%! legend ("X-Y errbars", "X-Y errboxes"); +%! title ('errorbar() with X-Y errorbars and error boxes');
--- a/scripts/plot/ezplot.m +++ b/scripts/plot/ezplot.m @@ -87,22 +87,22 @@ %!demo -%! ## sinc function using function handle +%! %% sinc function using function handle %! f = @(x) sin (pi*x) ./ (pi*x); %! ezplot (f); %!demo -%! ## example of a function string and explicit limits +%! %% example of a function string and explicit limits %! clf; %! ezplot ('1/x', [-2 2]); %!demo -%! ## parameterized function example over -2*pi <= t <= +2*pi +%! %% parameterized function example over -2*pi <= t <= +2*pi %! clf; %! ezplot (@cos, @sin); %!demo -%! ## implicit function of 2 variables +%! %% implicit function of 2 variables %! clf; %! ezplot (inline ('x^2 - y^2 - 1'));
--- a/scripts/plot/ezplot3.m +++ b/scripts/plot/ezplot3.m @@ -80,5 +80,5 @@ %! fx = @(t) cos (t); %! fy = @(t) sin (t); %! fz = @(t) t; -%! ezplot3 (fx, fy, fz, [0, 10*pi], 100, 'animate'); +%! ezplot3 (fx, fy, fz, [0, 5*pi], 100, 'animate');
--- a/scripts/plot/ezpolar.m +++ b/scripts/plot/ezpolar.m @@ -45,7 +45,7 @@ ## Example: ## ## @example -## ezpolar (@@(t) 1 + sin (t)); +## ezpolar (@@(t) sin (5/4 * t), [0, 8*pi]); ## @end example ## ## @seealso{polar, ezplot} @@ -68,5 +68,4 @@ %!demo %! clf; -%! ezpolar (@(t) 1 + sin (t)); - +%! ezpolar (@(t) sin (5/4 * t), [0, 8*pi]);
--- a/scripts/plot/feather.m +++ b/scripts/plot/feather.m @@ -119,4 +119,6 @@ %! clf; %! phi = [0 : 15 : 360] * pi/180; %! feather (sin (phi), cos (phi)); +%! axis tight; +%! title ('feather plot');
--- a/scripts/plot/fplot.m +++ b/scripts/plot/fplot.m @@ -184,16 +184,19 @@ %!demo %! clf; %! fplot (@cos, [0, 2*pi]); +%! title ('fplot() single function'); %!demo %! clf; %! fplot ('[cos(x), sin(x)]', [0, 2*pi]); +%! title ('fplot() multiple functions'); %!demo %! clf; -%! ## sinc function +%! %% sinc function %! fh = @(x) sin (pi*x) ./ (pi*x); %! fplot (fh, [-5, 5]); +%! title ('fplot() sinc function'); %!test %! [x, y] = fplot ("[cos(x), sin(x)]", [0, 2*pi]);
--- a/scripts/plot/hold.m +++ b/scripts/plot/hold.m @@ -119,11 +119,12 @@ %!demo %! clf; %! A = rand (100); -%! [X, Y] = find (A > 0.9); +%! [X, Y] = find (A > 0.95); %! imshow (A); %! hold on; %! plot (X, Y, 'o'); %! hold off; +%! title ('hold with image and plot'); %!demo %! clf;
--- a/scripts/plot/isosurface.m +++ b/scripts/plot/isosurface.m @@ -195,6 +195,7 @@ %! [x,y,z] = meshgrid (-2:0.5:2, -2:0.5:2, -2:0.5:2); %! v = x.^2 + y.^2 + z.^2; %! isosurface (x, y, z, v, 1); +%! title ('isosurface of a sphere'); %!shared x, y, z, val %! [x, y, z] = meshgrid (0:1, 0:1, 0:1); # Points for single
--- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -1337,7 +1337,7 @@ %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382]; %! bar (rand_2x3_data1); %! ylim ([0 1.0]); -%! title ('legend() works for bar graphs (hgobjects)'); +%! title ('legend() works for bar graphs (hggroups)'); %! legend ({'1st Bar', '2nd Bar', '3rd Bar'}); %!demo @@ -1345,7 +1345,7 @@ %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531]; %! bar (rand_2x3_data2); %! ylim ([0 1.2]); -%! title ('legend() works for bar graphs (hgobjects)'); +%! title ('legend() works for bar graphs (hggroups)'); %! legend ('1st Bar', '2nd Bar', '3rd Bar'); %! legend right; @@ -1554,6 +1554,7 @@ %! legend (option); %!demo % bug 39697 +%! clf; %! plot (1:10); %! legend ("Legend Text"); %! title ({"Multi-line", "titles", "are a", "problem"});
--- a/scripts/plot/loglog.m +++ b/scripts/plot/loglog.m @@ -75,6 +75,7 @@ %! x = sort ((t .* (1 + rand (size (t)))) .^ 2); %! y = (t .* (1 + rand (size (t)))) .^ 2; %! loglog (x, y); +%! title ({'loglog() plot', 'Both axes are logarithmic'}); %!demo %! clf;
--- a/scripts/plot/loglogerr.m +++ b/scripts/plot/loglogerr.m @@ -79,4 +79,6 @@ %! eyl = 0.5*rand (size (y)) .* y; %! loglogerr (x, y, eyl, eyu, '#~x-'); %! xlim (x([1, end])); +%! title ({'loglogerr(): loglog() plot with errorbars', ... +%! 'Both axes are logarithmic'});
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -92,10 +92,21 @@ %! clf; %! x = logspace (0,1,11); %! z = x'*x; +%! mesh (x, x, z); +%! xlabel 'X-axis'; +%! ylabel 'Y-axis'; +%! zlabel 'Z-axis'; +%! title ('mesh() with color proportional to height'); + +%!demo +%! clf; +%! x = logspace (0,1,11); +%! z = x'*x; %! mesh (x, x, z, z.^2); %! xlabel 'X-axis'; %! ylabel 'Y-axis'; %! zlabel 'linear scale'; +%! title ('mesh() with color proportional to Z^2'); %!demo %! clf; @@ -106,6 +117,7 @@ %! xlabel 'X-axis'; %! ylabel 'Y-axis'; %! zlabel 'log scale'; +%! title ({'mesh() with color proportional to Z^2', 'Z-axis is log scale'}); %! if (strcmp (get (gcf, '__graphics_toolkit__'), 'gnuplot')) %! title ({'Gnuplot: mesh color is wrong', 'This is a Gnuplot bug'}); %! endif
--- a/scripts/plot/meshc.m +++ b/scripts/plot/meshc.m @@ -97,3 +97,12 @@ endfunction + +%!demo +%! clf; +%! colormap ('default'); +%! [X, Y] = meshgrid (linspace (-3, 3, 40)); +%! Z = sqrt (abs (X .* Y)) ./ (1 + X.^2 + Y.^2); +%! meshc (X, Y, Z); +%! title ('meshc() combines mesh/contour plots'); +
--- a/scripts/plot/meshz.m +++ b/scripts/plot/meshz.m @@ -133,6 +133,20 @@ %! colormap ('default'); %! Z = peaks (); %! meshz (Z); +%! title ('meshz() plot of peaks() function'); + +%!demo +%! clf; +%! colormap ('default'); +%! Z = peaks (); +%! subplot (1,2,1) +%! mesh (Z); +%! daspect ([2.5, 2.5, 1]); +%! title ('mesh() plot'); +%! subplot (1,2,2) +%! meshz (Z); +%! daspect ([2.5, 2.5, 1]); +%! title ('meshz() plot'); %!demo %! clf; @@ -141,4 +155,5 @@ %! [fx, fy] = gradient (Z); %! C = sqrt (fx.^2 + fy.^2); %! meshz (X,Y,Z,C); +%! title ('meshz() plot with color determined by gradient');
--- a/scripts/plot/patch.m +++ b/scripts/plot/patch.m @@ -222,7 +222,6 @@ %! x = [ 0 0; 1 1; 1 0 ]; %! y = [ 0 0; 0 1; 1 1 ]; %! p = patch (x, y, 'facecolor', 'b'); -%! title ('Two blue triangles'); %! set (p, 'cdatamapping', 'direct', 'facecolor', 'flat', 'cdata', [1 32]); %! title ('Direct mapping of colors: Light-Green UL and Blue LR triangles');
--- a/scripts/plot/pcolor.m +++ b/scripts/plot/pcolor.m @@ -103,6 +103,7 @@ %! colormap ('default'); %! Z = peaks (); %! pcolor (Z); +%! title ('pcolor() of peaks with facet shading'); %!demo %! clf; @@ -112,4 +113,5 @@ %! pcolor (X,Y,Fx+Fy); %! shading interp; %! axis tight; +%! title ('pcolor() of peaks with interp shading');
--- a/scripts/plot/pie.m +++ b/scripts/plot/pie.m @@ -81,17 +81,20 @@ %! 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]); +%! title ('pie() with exploded wedge'); %!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]); +%! title ('pie() with labels'); + %!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]); -%! title ('missing slice'); +%! title ('pie() with missing slice');
--- a/scripts/plot/pie3.m +++ b/scripts/plot/pie3.m @@ -82,17 +82,19 @@ %! 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]); +%! title ('pie3() with exploded wedge'); %!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]); +%! title ('pie3() with labels'); %!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]); -%! title ('missing slice'); +%! title ('pie3() with missing slice');
--- a/scripts/plot/plot.m +++ b/scripts/plot/plot.m @@ -209,17 +209,18 @@ %!demo %! x = 1:5; y = 1:5; %! plot (x,y,'g'); -%! title ('plot of green line at 45 degrees'); +%! title ('plot() of green line at 45 degrees'); %!demo %! x = 1:5; y = 1:5; %! plot (x,y,'g*'); -%! title ('plot of green stars along a line at 45 degrees'); +%! title ('plot() of green stars along a line at 45 degrees'); %!demo %! x1 = 1:5; y1 = 1:5; %! x2 = 5:9; y2 = 5:-1:1; %! plot (x1,y1,'bo-', x2,y2,'rs-'); %! axis ('tight'); -%! title ('plot of blue circles ascending and red squares descending with connecting lines drawn'); +%! title ({'plot() of blue circles ascending and red squares descending'; +%! 'connecting lines drawn'});
--- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -375,9 +375,11 @@ %! clf; %! z = [0:0.05:5]; %! plot3 (cos (2*pi*z), sin (2*pi*z), z, ';helix;'); +%! title ('plot3() of a helix'); %!demo %! clf; %! z = [0:0.05:5]; %! plot3 (z, exp (2i*pi*z), ';complex sinusoid;'); +%! title ('plot3() with complex input');
--- a/scripts/plot/polar.m +++ b/scripts/plot/polar.m @@ -196,16 +196,19 @@ %! theta = linspace (0,2*pi,1000); %! rho = sin (7*theta); %! polar (theta, rho); +%! title ('polar() plot'); %!demo %! clf; %! theta = linspace (0,2*pi,1000); %! cplx = theta + i*sin (7*theta); %! polar (cplx, 'g'); +%! title ('polar() plot of complex data'); %!demo %! clf; -%! theta = linspace (0,10*pi,1000); +%! theta = linspace (0,8*pi,1000); %! rho = sin (5/4*theta); %! polar (theta, rho); +%! title ('polar() plot');
--- a/scripts/plot/rectangle.m +++ b/scripts/plot/rectangle.m @@ -222,15 +222,18 @@ %! clf; %! axis equal; %! rectangle ('Position', [0.05, 0.05, 0.9, 0.9], 'Curvature', [0.5, 0.5]); +%! title ('rectangle() with corners curved'); %!demo %! clf; %! axis equal; %! rectangle ('Position', [0.05, 0.05, 0.9, 0.4], 'Curvature', 1.0); +%! title ('rectangle() with sides as complete arcs'); %!demo %! clf; %! axis equal; %! h = rectangle ('Position', [0.05, 0.05, 0.9, 0.4], 'Curvature', 1.0); %! set (h, 'FaceColor', [0, 1, 0]); +%! title ('rectangle() with FaceColor = green');
--- a/scripts/plot/ribbon.m +++ b/scripts/plot/ribbon.m @@ -116,6 +116,7 @@ %! [x, y, z] = sombrero (); %! [~, y] = meshgrid (x, y); %! ribbon (y, z); +%! title ('ribbon() plot of sombrero()'); %!FIXME: Could have some input validation tests here
--- a/scripts/plot/rose.m +++ b/scripts/plot/rose.m @@ -114,4 +114,5 @@ %!demo %! clf; %! rose ([2*randn(1e5, 1), pi + 2*randn(1e5, 1)]); +%! title ('rose() angular histogram plot');
--- a/scripts/plot/scatter.m +++ b/scripts/plot/scatter.m @@ -99,7 +99,7 @@ %! x = randn (100, 1); %! y = randn (100, 1); %! scatter (x, y, 'r'); -%! title ('Scatter plot with red bubbles'); +%! title ('scatter() plot with red bubbles'); %!demo %! clf; @@ -107,14 +107,37 @@ %! y = randn (100, 1); %! c = x .* y; %! scatter (x, y, 20, c, 'filled'); -%! title ('Scatter with colors'); +%! title ('scatter() with colored filled bubbles'); %!demo %! clf; %! x = randn (100, 1); %! y = randn (100, 1); %! scatter (x, y, [], sqrt (x.^2 + y.^2)); -%! title ('Scatter plot with bubble color determined by distance from origin'); +%! title ({'scatter() plot'; ... +%! 'bubble color determined by distance from origin'}); + +%!demo +%! clf; +%! rand_10x1_data5 = [0.777753, 0.093848, 0.183162, 0.399499, 0.337997, 0.686724, 0.073906, 0.651808, 0.869273, 0.137949]; +%! rand_10x1_data6 = [0.37460, 0.25027, 0.19510, 0.51182, 0.54704, 0.56087, 0.24853, 0.75443, 0.42712, 0.44273]; +%! x = rand_10x1_data5; +%! y = rand_10x1_data6; +%! s = 10 - 10*log (x.^2 + y.^2); +%! h = scatter (x, y, [], 'r', 's'); +%! title ({'scatter() plot'; ... +%! 'marker is square, color is red'}); + +%!demo +%! clf; +%! rand_10x1_data3 = [0.42262, 0.51623, 0.65992, 0.14999, 0.68385, 0.55929, 0.52251, 0.92204, 0.19762, 0.93726]; +%! rand_10x1_data4 = [0.020207, 0.527193, 0.443472, 0.061683, 0.370277, 0.947349, 0.249591, 0.666304, 0.134247, 0.920356]; +%! x = rand_10x1_data3; +%! y = rand_10x1_data4; +%! s = 10 - 10*log (x.^2 + y.^2); +%! h = scatter (x, y, [], 'r', 's', 'filled'); +%! title ({'scatter() plot'; ... +%! 'marker is square, marker is filled, color is red'}); %!demo %! clf; @@ -124,29 +147,11 @@ %! y = rand_10x1_data2; %! s = 10 - 10*log (x.^2 + y.^2); %! h = scatter (x, y, s, s, 's', 'filled'); -%! title ({'Scatter plot with filled square markers', ... +%! title ({'scatter() plot with filled square markers', ... %! 'size and color of markers determined by algorithm'}); %!demo %! clf; -%! rand_10x1_data3 = [0.42262, 0.51623, 0.65992, 0.14999, 0.68385, 0.55929, 0.52251, 0.92204, 0.19762, 0.93726]; -%! rand_10x1_data4 = [0.020207, 0.527193, 0.443472, 0.061683, 0.370277, 0.947349, 0.249591, 0.666304, 0.134247, 0.920356]; -%! x = rand_10x1_data3; -%! y = rand_10x1_data4; -%! s = 10 - 10*log (x.^2 + y.^2); -%! h = scatter (x, y, [], 'r', 's', 'filled'); - -%!demo -%! clf; -%! rand_10x1_data5 = [0.777753, 0.093848, 0.183162, 0.399499, 0.337997, 0.686724, 0.073906, 0.651808, 0.869273, 0.137949]; -%! rand_10x1_data6 = [0.37460, 0.25027, 0.19510, 0.51182, 0.54704, 0.56087, 0.24853, 0.75443, 0.42712, 0.44273]; -%! x = rand_10x1_data5; -%! y = rand_10x1_data6; -%! s = 10 - 10*log (x.^2 + y.^2); -%! h = scatter (x, y, [], 'r', 's'); - -%!demo -%! clf; %! k = 1; %! for m = [1, 3] %! for n = [101, 50, 1]
--- a/scripts/plot/scatter3.m +++ b/scripts/plot/scatter3.m @@ -100,24 +100,27 @@ %! clf; %! [x, y, z] = peaks (20); %! scatter3 (x(:), y(:), z(:), [], z(:)); -%! %% Default scatter3 with constant size bubbles and color determined by Z +%! title ({'Default scatter3() plot', ... +%! 'constant size bubbles and color determined by Z'}); %!demo %! clf; %! x = rand (20,1); y = rand (20,1); z = rand (20,1); %! scatter3 (x(:), y(:), z(:), 10, z(:), 's'); -%! %% scatter3 using a square marker of size 10 and color determined by Z +%! title ({'scatter3() plot', ... +%! 'marker is square, size is 10, color determined by Z'}); %!demo %! clf; %! x = rand (20,1); y = rand (20,1); z = rand (20,1); %! scatter3 (x(:), y(:), z(:), 20*z(:), [], 's'); -%! %% scatter3 using a square marker whose size is determined by Z +%! title ({'scatter3() plot', ... +%! 'marker is square, size is determined by Z'}); %!demo %! clf; %! x = rand (20,1); y = rand (20,1); z = rand (20,1); %! scatter3 (x(:), y(:), z(:), 20*z(:), z(:), 's'); -%! %% scatter3 using a square marker. -%! %% Size and color of marker are determined by Z +%! title ({'scatter3() plot', ... +%! 'marker is square, size and color determined by Z'});
--- a/scripts/plot/semilogx.m +++ b/scripts/plot/semilogx.m @@ -74,6 +74,7 @@ %! x = 1:0.01:10; %! y = (x .* (1 + rand (size (x)))) .^ 2; %! semilogx (y, x); +%! title ({'semilogx() plot', 'X-axis is logarithmic'}); %!demo %! clf;
--- a/scripts/plot/semilogxerr.m +++ b/scripts/plot/semilogxerr.m @@ -81,4 +81,6 @@ %! ey = 0.5*rand (size (y)) .* y; %! semilogxerr (x, y, ey, '#~x-'); %! xlim (x([1, end])); +%! title ({'semilogxerr(): semilogx() plot with errorbars', ... +%! 'X-axis is logarithmic'});
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -74,6 +74,7 @@ %! x = 1:0.01:10; %! y = (x .* (1 + rand (size (x)))) .^ 2; %! semilogy (x, y); +%! title ({'semilogx() plot', 'Y-axis is logarithmic'}); %!demo %! clf;
--- a/scripts/plot/semilogyerr.m +++ b/scripts/plot/semilogyerr.m @@ -82,4 +82,6 @@ %! eyl = 1.0 - 1./(1+eyu); %! semilogyerr (x, y, eyl.*y, eyu.*y, '~-d'); %! xlim ([0 10]); +%! title ({'semilogyerr(): semilogy() plot with errorbars', ... +%! 'Y-axis is logarithmic'});
--- a/scripts/plot/sombrero.m +++ b/scripts/plot/sombrero.m @@ -80,6 +80,7 @@ %! clf; %! colormap ('default'); %! sombrero (); +%! title ('sombrero() function'); ## Test input validation %!error sombrero (1,2,3)
--- a/scripts/plot/stem3.m +++ b/scripts/plot/stem3.m @@ -77,4 +77,5 @@ %! clf; %! theta = 0:0.2:6; %! stem3 (cos (theta), sin (theta), theta); +%! title ('stem3() plot');
--- a/scripts/plot/surf.m +++ b/scripts/plot/surf.m @@ -91,6 +91,7 @@ %! colormap ('default'); %! Z = peaks (); %! surf (Z); +%! title ({'surf() plot of peaks() function'; 'color determined by height Z'}); %!demo %! clf; @@ -99,6 +100,8 @@ %! [Fx,Fy] = gradient (Z); %! surf (Z, Fx+Fy); %! shading interp; +%! title ({'surf() plot of peaks() function'; ... +%! 'facecolor is interpolated, color determined by gradient of Z'}); %!demo %! clf; @@ -107,4 +110,6 @@ %! [~,Fy] = gradient (Z); %! surf (X, Y, Z, Fy); %! shading interp; +%! title ({'surf() plot of peaks() function'; ... +%! 'facecolor is interpolated, color determined by Y-gradient of Z'});
--- a/scripts/plot/surfc.m +++ b/scripts/plot/surfc.m @@ -115,6 +115,7 @@ %! colormap ('default'); %! Z = peaks (); %! surfc (Z); +%! title ('surfc() combines surf/contour plots'); %!demo %! clf; @@ -123,6 +124,8 @@ %! [Fx,Fy] = gradient (Z); %! surfc (Z, Fx+Fy); %! shading interp; +%! title ({'surfc() plot of sombrero() function'; ... +%! 'facecolor is interpolated, color determined by gradient of Z'}); %!demo %! clf; @@ -131,4 +134,6 @@ %! [~,Fy] = gradient (Z); %! surfc (X,Y,Z,Fy); %! shading interp; +%! title ({'surfc() plot of peaks() function'; ... +%! 'facecolor is interpolated, color determined by Y-gradient of Z'});
--- a/scripts/plot/surfl.m +++ b/scripts/plot/surfl.m @@ -195,7 +195,7 @@ %! colormap (copper (64)); %! surfl (X,Y,Z); %! shading interp; -%! title ('surfl with defaults'); +%! title ('surfl() with defaults'); %!demo %! clf; @@ -204,5 +204,5 @@ %! [az, el] = view (); %! surfl (X,Y,Z, [az+225,el], [0.2 0.6 0.4 25]); %! shading interp; -%! title ('surfl with lighting vector and material properties'); +%! title ('surfl() with lighting vector and material properties');
--- a/scripts/plot/title.m +++ b/scripts/plot/title.m @@ -61,24 +61,38 @@ %! clf; %! ax = axes (); %! h = get (ax, 'title'); -%! title ('Testing title'); -%! assert (get (h, 'string'), 'Testing title'); +%! title ('Test Title Text'); + +%!demo +%! clf; +%! ax = axes (); +%! h = get (ax, 'title'); +%! title ({'Multi-line'; 'Title'; 'Text'}); %!demo %! clf; %! plot3 ([0,1], [0,1], [0,1]); %! h = get (gca, 'title'); -%! title ('Testing title', 'fontsize', 16); -%! assert (get (h, 'string'), 'Testing title'); -%! assert (get (h, 'fontsize'), 16); +%! title ('Test FontSize Property', 'fontsize', 16); %!test %! hf = figure ("visible", "off"); %! unwind_protect %! ax = axes (); %! h = get (ax, "title"); -%! title ("Testing title"); -%! assert (get (h, "string"), "Testing title"); +%! title ("Test Title Text"); +%! assert (get (h, "string"), "Test Title Text"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure ("visible", "off"); +%! unwind_protect +%! ax = axes (); +%! h = get (ax, "title"); +%! title ({'Multi-line'; 'Title'; 'Text'}); +%! assert (get (h, "string"), {'Multi-line'; 'Title'; 'Text'}); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect @@ -88,8 +102,10 @@ %! unwind_protect %! plot3 ([0,1], [0,1], [0,1]); %! h = get (gca, "title"); -%! title ("Testing title"); -%! assert (get (h, "string"), "Testing title"); +%! title ("Test FontSize Property", "fontsize", 16); +%! assert (get (h, "string"), "Test FontSize Property"); +%! assert (get (h, "fontsize"), 16); + %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect
--- a/scripts/plot/waterfall.m +++ b/scripts/plot/waterfall.m @@ -82,4 +82,18 @@ %! colormap ('default'); %! Z = peaks (); %! waterfall (Z); +%! title ('waterfall() plot of peaks() function'); +%!demo +%! clf; +%! colormap ('default'); +%! Z = peaks (); +%! subplot (1,2,1) +%! meshz (Z); +%! daspect ([2.5, 2.5, 1]); +%! title ('meshz() plot'); +%! subplot (1,2,2) +%! waterfall (Z); +%! daspect ([2.5, 2.5, 1]); +%! title ('waterfall() plot'); +