Mercurial > octave
diff doc/interpreter/geometryimages.m @ 9912:e9fe12c1b0c0
Set default papersize to the desired imagesize
Set default paperorientation to landscape to stop warning message
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Fri, 04 Dec 2009 09:45:15 -0800 |
parents | eb63fbe60fab |
children | e76d8c767584 |
line wrap: on
line diff
--- a/doc/interpreter/geometryimages.m Fri Dec 04 12:28:52 2009 -0500 +++ b/doc/interpreter/geometryimages.m Fri Dec 04 09:45:15 2009 -0800 @@ -17,10 +17,12 @@ ## <http://www.gnu.org/licenses/>. function geometryimages (nm, typ) - bury_output (); + set_print_size (); + hide_output (); if (strcmp (typ, "png")) set (0, "defaulttextfontname", "*"); endif + if (isempty (findstr (octave_config_info ("DEFS"), "HAVE_QHULL")) && (strcmp (nm, "voronoi") || strcmp (nm, "griddata") || strcmp (nm, "convhull") || strcmp (nm, "delaunay") @@ -90,7 +92,7 @@ else error ("unrecognized plot requested"); endif - bury_output (); + hide_output (); endfunction function [r, c] = tri2circ (tri, xx, yy) @@ -104,68 +106,19 @@ r = sqrt ((xc - x(1)).^2 + (yc - y(1)).^2); endfunction -## Use this function before plotting commands and after every call to -## print since print() resets output to stdout (unfortunately, gnpulot -## can't pop output as it can the terminal type). -function bury_output () - f = figure (1); - set (f, "visible", "off"); -endfunction -function geometryimages (nm, typ) - bury_output (); - if (strcmp (nm, "voronoi")) - rand("state",9); - x = rand(10,1); - y = rand(10,1); - tri = delaunay (x, y); - [vx, vy] = voronoi (x, y, tri); - triplot (tri, x, y, "b"); - hold on; - plot (vx, vy, "r"); - [r, c] = tri2circ (tri(end,:), x, y); - pc = [-1:0.01:1]; - xc = r * sin(pi*pc) + c(1); - yc = r * cos(pi*pc) + c(2); - plot (xc, yc, "g-", "LineWidth", 3); - axis([0, 1, 0, 1]); - legend ("Delaunay Triangulation", "Voronoi Diagram"); - print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) - elseif (strcmp (nm, "triplot")) - rand ("state", 2) - x = rand (20, 1); - y = rand (20, 1); - tri = delaunay (x, y); - triplot (tri, x, y); - print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) - elseif (strcmp (nm, "griddata")) - rand("state",1); - x=2*rand(1000,1)-1; - y=2*rand(size(x))-1; - z=sin(2*(x.^2+y.^2)); - [xx,yy]=meshgrid(linspace(-1,1,32)); - griddata(x,y,z,xx,yy); - print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)) - else - error ("unrecognized plot requested"); - endif - bury_output (); -endfunction - -function [r, c] = tri2circ (tri, xx, yy) - x = xx(tri); - y = yy(tri); - m = (y(1:end-1) - y(2:end)) ./ (x(1:end-1) - x(2:end)); - xc = (prod(m) .* (y(1) - y(end)) + m(end)*(x(1)+x(2)) - m(1)*(x(2)+x(3))) ... - ./ (2 * (m(end) - m(1))); - yc = - (xc - (x(2) + x(3))./2) ./ m(end) + (y(2) + y(3)) / 2; - c = [xc, yc]; - r = sqrt ((xc - x(1)).^2 + (yc - y(1)).^2); +function set_print_size () + image_size = [5.0, 3.5]; # in inches, 16:9 format + border = 0; # For postscript use 50/72 + set (0, "defaultfigurepapertype", "<custom>"); + set (0, "defaultfigurepaperorientation", "landscape"); + set (0, "defaultfigurepapersize", image_size + 2*border); + set (0, "defaultfigurepaperposition", [border, border, image_size]); endfunction ## Use this function before plotting commands and after every call to ## print since print() resets output to stdout (unfortunately, gnpulot ## can't pop output as it can the terminal type). -function bury_output () +function hide_output () f = figure (1); set (f, "visible", "off"); endfunction @@ -181,7 +134,7 @@ return; else ## if (!strcmp (typ, "txt")) - bury_output (); + hide_output (); x = y = linspace (-8, 8, 41)'; [xx, yy] = meshgrid (x, y); @@ -192,7 +145,7 @@ title ("Sorry, graphics not available because octave was\\ncompiled without the QHULL library."); unwind_protect_cleanup print (cstrcat (nm, ".", typ), cstrcat ("-d", typ)); - bury_output (); + hide_output (); end_unwind_protect endif endfunction