diff scripts/plot/legend.m @ 14237:11949c9795a0

Revamp %!demos in m-files to use Octave coding conventions on spacing, etc. Add clf() to all demos using plot features to get reproducibility. Use 64 as input to all colormaps (jet (64)) to get reproducibility. * bicubic.m, cell2mat.m, celldisp.m, cplxpair.m, interp1.m, interp2.m, interpft.m, interpn.m, profile.m, profshow.m, convhull.m, delaunay.m, griddata.m, inpolygon.m, voronoi.m, autumn.m, bone.m, contrast.m, cool.m, copper.m, flag.m, gmap40.m, gray.m, hot.m, hsv.m, image.m, imshow.m, jet.m, ocean.m, pink.m, prism.m, rainbow.m, spring.m, summer.m, white.m, winter.m, condest.m, onenormest.m, axis.m, clabel.m, colorbar.m, comet.m, comet3.m, compass.m, contour.m, contour3.m, contourf.m, cylinder.m, daspect.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, fill.m, fplot.m, grid.m, hold.m, isosurface.m, legend.m, loglog.m, loglogerr.m, pareto.m, patch.m, pbaspect.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m, plotyy.m, polar.m, quiver.m, quiver3.m, rectangle.m, refreshdata.m, ribbon.m, rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shading.m, slice.m, sombrero.m, stairs.m, stem.m, stem3.m, subplot.m, surf.m, surfc.m, surfl.m, surfnorm.m, text.m, title.m, trimesh.m, triplot.m, trisurf.m, uigetdir.m, uigetfile.m, uimenu.m, uiputfile.m, waitbar.m, xlim.m, ylim.m, zlim.m, mkpp.m, pchip.m, polyaffine.m, spline.m, bicgstab.m, cgs.m, gplot.m, pcg.m, pcr.m, treeplot.m, strtok.m, demo.m, example.m, rundemos.m, speed.m, test.m, calendar.m, datestr.m, datetick.m, weekday.m: Revamp %!demos to use Octave coding conventions on spacing, etc.
author Rik <octave@nomad.inbox5.com>
date Fri, 20 Jan 2012 12:59:53 -0800
parents 35903f035390
children 4506eade9f04
line wrap: on
line diff
--- a/scripts/plot/legend.m	Thu Jan 19 19:48:13 2012 -0500
+++ b/scripts/plot/legend.m	Fri Jan 20 12:59:53 2012 -0800
@@ -972,199 +972,197 @@
   endif
 endfunction
 
-%!demo
-%! clf
-%! x = 0:1;
-%! plot (x, x, ";I am Blue;", x, 2*x, ";I am Green;", x, 3*x, ";I am Red;")
 
 %!demo
-%! clf
+%! clf;
+%! x = 0:1;
+%! plot (x,x,";I am Blue;", x,2*x,";I am Green;", x,3*x,";I am Red;");
+
+%!demo
+%! clf;
 %! x = 0:1;
 %! plot (x, x, ";\alpha;",
 %!       x, 2*x, ";\beta=2\alpha;",
-%!       x, 3*x, ";\gamma=3\alpha;")
+%!       x, 3*x, ";\gamma=3\alpha;");
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:1;
-%! plot (x, x, ";I am Blue;", x, 2*x, x, 3*x, ";I am Red;")
-%! title ("Blue and Green keys, with Green mising")
+%! plot (x,x,";I am Blue;", x,2*x, x,3*x,";I am Red;");
+%! title ("Blue and Green keys, with Green missing");
 
 %!demo
-%! clf
-%! plot(1:10, 1:10, 1:10, fliplr(1:10));
-%! title("incline is blue and decline is green");
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend hide
-%! legend show
+%! clf;
+%! plot (1:10, 1:10, 1:10, fliplr (1:10));
+%! title ("incline is blue and decline is green");
+%! legend ({"I am blue", "I am green"}, "location", "east");
 
 %!demo
-%! clf
-%! plot(1:10, 1:10, 1:10, fliplr(1:10));
-%! title("Legend is hidden")
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend hide
+%! clf;
+%! plot (1:10, 1:10, 1:10, fliplr (1:10));
+%! title ("Legend is hidden")
+%! legend ({"I am blue", "I am green"}, "location", "east");
+%! legend hide;
 
 %!demo
-%! clf
-%! plot(1:10, 1:10, 1:10, fliplr(1:10));
-%! title("Legend with box on")
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend boxon
+%! clf;
+%! plot (1:10, 1:10, 1:10, fliplr (1:10));
+%! title ("Legend with box on");
+%! legend ({"I am blue", "I am green"}, "location", "east");
+%! legend boxon;
 
 %!demo
-%! clf
-%! plot(1:10, 1:10, 1:10, fliplr(1:10));
-%! title("Legend with text to the right")
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend right
+%! clf;
+%! plot (1:10, 1:10, 1:10, fliplr (1:10));
+%! title ("Legend with text to the right");
+%! legend ({"I am blue", "I am green"}, "location", "east");
+%! legend right;
 
 %!demo
-%! clf
-%! plot(1:10, 1:10);
-%! title("a very long label can sometimes cause problems");
-%! legend({"hello world"}, "location", "northeastoutside");
+%! clf;
+%! plot (1:10, 1:10);
+%! title ("a very long label can sometimes cause problems");
+%! legend ({"hello world"}, "location", "northeastoutside");
 
 %!demo
-%! clf
-%! plot(1:10, 1:10);
-%! title("a very long label can sometimes cause problems");
-%! legend("hello world", "location", "northeastoutside");
+%! clf;
+%! plot (1:10, 1:10);
+%! title ("a very long label can sometimes cause problems");
+%! legend ("hello world", "location", "northeastoutside");
 
 %!demo
-%! clf
+%! clf;
 %! labels = {};
 %! colororder = get (gca, "colororder");
 %! for i = 1:5
-%!   h = plot(1:100, i + rand(100,1)); hold on;
-%!   set (h, "color", colororder(i,:))
-%!   labels = {labels{:}, cstrcat("Signal ", num2str(i))};
+%!   h = plot (1:100, i + rand(100,1)); hold on;
+%!   set (h, "color", colororder(i,:));
+%!   labels = {labels{:}, cstrcat("Signal ", num2str (i))};
 %! endfor
 %! hold off;
-%! title("Signals with random offset and uniform noise")
-%! xlabel("Sample Nr [k]"); ylabel("Amplitude [V]");
-%! legend(labels, "location", "southoutside");
-%! legend("boxon");
+%! title ("Signals with random offset and uniform noise");
+%! xlabel ("Sample Nr [k]"); ylabel ("Amplitude [V]");
+%! legend (labels, "location", "southoutside");
+%! legend ("boxon");
 
 %!demo
-%! clf
+%! clf;
 %! labels = {};
 %! colororder = get (gca, "colororder");
 %! for i = 1:5
-%!   h = plot(1:100, i + rand(100,1)); hold on;
-%!   set (h, "color", colororder(i,:))
-%!   labels = {labels{:}, cstrcat("Signal ", num2str(i))};
+%!   h = plot (1:100, i + rand (100,1)); hold on;
+%!   set (h, "color", colororder(i,:));
+%!   labels = {labels{:}, cstrcat("Signal ", num2str (i))};
 %! endfor
 %! hold off;
-%! title("Signals with random offset and uniform noise")
-%! xlabel("Sample Nr [k]"); ylabel("Amplitude [V]");
-%! legend(labels{:}, "location", "southoutside")
-%! legend("boxon")
+%! title ("Signals with random offset and uniform noise");
+%! xlabel ("Sample Nr [k]"); ylabel ("Amplitude [V]");
+%! legend (labels{:}, "location", "southoutside");
+%! legend ("boxon");
 
 %!demo
-%! clf
+%! clf;
 %! x = linspace (0, 10);
 %! plot (x, x);
-%! hold ("on");
-%! stem (x, x.^2, 'g')
+%! hold on;
+%! stem (x, x.^2, 'g');
 %! legend ("linear");
-%! hold ("off");
+%! hold off;
 
 %!demo
-%! clf
+%! clf;
 %! x = linspace (0, 10);
 %! plot (x, x, x, x.^2);
 %! legend ("linear");
 
 %!demo
-%! clf
+%! clf;
 %! x = linspace (0, 10);
 %! plot (x, x, x, x.^2);
 %! legend ("linear", "quadratic");
 
 %!demo
-%! clf
+%! clf;
 %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382];
 %! bar (rand_2x3_data1);
 %! ylim ([0 1.0]);
 %! legend ({"1st Bar", "2nd Bar", "3rd Bar"});
 
 %!demo
-%! clf
+%! clf;
 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531];
 %! bar (rand_2x3_data2);
 %! ylim ([0 1.2]);
 %! legend ("1st Bar", "2nd Bar", "3rd Bar");
-%! legend right
+%! legend right;
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.1:7;
-%! h = plot (x, sin(x), x, cos(x), x, sin(x.^2/10), x, cos(x.^2/10));
+%! h = plot (x,sin(x), x,cos(x), x,sin(x.^2/10), x,cos(x.^2/10));
 %! title ("Only the sin() objects have keylabels");
 %! legend (h([1, 3]), {"sin(x)", "sin(x^2/10)"}, "location", "southwest");
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.1:10;
-%! plot (x, sin(x), ";sin(x);")
-%! hold all
-%! plot (x, cos(x), ";cos(x);")
-%! hold off
+%! plot (x, sin(x), ";sin(x);");
+%! hold all;
+%! plot (x, cos(x), ";cos(x);");
+%! hold off;
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.1:10;
-%! plot (x, sin(x), ";sin(x);")
-%! hold all
-%! plot (x, cos(x), ";cos(x);")
-%! hold off
-%! legend ({"sin(x)", "cos(x)"}, "location", "northeastoutside")
+%! plot (x, sin(x), ";sin(x);");
+%! hold all;
+%! plot (x, cos(x), ";cos(x);");
+%! hold off;
+%! legend ({"sin(x)", "cos(x)"}, "location", "northeastoutside");
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:10;
 %! plot (x, rand (11));
-%! xlabel ("Indices")
-%! ylabel ("Random Values")
-%! title ("Legend ""off"" should delete the legend")
-%! legend (cellstr (num2str ((1:10)')), "location", "northeastoutside")
-%! legend off
-%! axis ([0, 10, 0 1])
+%! xlabel ("Indices");
+%! ylabel ("Random Values");
+%! title ('Legend "off" should delete the legend');
+%! legend (cellstr (num2str ((1:10)')), "location", "northeastoutside");
+%! legend off;
+%! axis ([0, 10, 0 1]);
 
 %!demo
-%! clf
-%! x = 1:5;
-%! subplot (2, 2, 1)
-%! plot (x, rand (numel (x)));
-%! legend (cellstr (num2str (x')), "location", "northwestoutside")
-%! legend boxon
-%! subplot (2, 2, 2)
-%! plot (x, rand (numel (x)));
-%! legend (cellstr (num2str (x')), "location", "northeastoutside")
-%! legend boxon
+%! clf;
+%! x = (1:5)';
+%! subplot (2, 2, 1);
+%!  plot (x, rand (numel (x)));
+%!  legend (cellstr (num2str (x)), "location", "northwestoutside");
+%!  legend boxon;
+%! subplot (2, 2, 2);
+%!  plot (x, rand (numel (x)));
+%!  legend (cellstr (num2str (x)), "location", "northeastoutside");
+%!  legend boxon;
 %! subplot (2, 2, 3);
-%! plot (x, rand (numel (x)));
-%! legend (cellstr (num2str (x')), "location", "southwestoutside")
-%! legend boxon
-%! subplot (2, 2, 4)
-%! plot (x, rand (numel (x)));
-%! legend (cellstr (num2str (x')), "location", "southeastoutside")
-%! legend boxon
+%!  plot (x, rand (numel (x)));
+%!  legend (cellstr (num2str (x)), "location", "southwestoutside");
+%!  legend boxon;
+%! subplot (2, 2, 4);
+%!  plot (x, rand (numel (x)));
+%!  legend (cellstr (num2str (x)), "location", "southeastoutside");
+%!  legend boxon;
 
 %!demo
-%! clf
-%! plot (rand (2))
-%! title ("Warn of extra labels")
-%! legend ("Hello", "World", "interpreter", "foobar")
+%! clf;
+%! plot (rand (2));
+%! title ("Warn of extra labels");
+%! legend ("Hello", "World", "interpreter", "foobar");
 
 %!demo
-%! clf
-%! plot (rand (2))
-%! title ("Turn off TeX interpreter")
+%! clf;
+%! plot (rand (2));
+%! title ("Turn off TeX interpreter");
 %! h = legend ("Hello_World", "foo^bar");
-%! set (h, "interpreter", "none")
+%! set (h, "interpreter", "none");
 
 %!demo
 %! x = 0:10;
@@ -1187,20 +1185,3 @@
 %! [ax, h1, h2] = plotyy (x, y1, x, y2);
 %! legend ("Blue", "Green", "location", "south");
 
-%!test
-%! x = 0:10;
-%! y = rand (size (x));
-%! displayname = '\alpha_\beta \delta^\theta';
-%! displayname1 = "";
-%! displayname2 = "";
-%! figure (1, "visible", false)
-%! unwind_protect
-%!   h = plot (x, y, sprintf (";%s;", displayname));
-%!   displayname1 = get (h, "displayname")
-%!   hlegend = legend (h, displayname, "location", "south");
-%!   displayname2 = get (h, "displayname")
-%! unwind_protect_cleanup
-%!   close (gcf;
-%! end_unwind_protect
-%! assert (displayname1, displayname)
-%! assert (displayname2, displayname)