changeset 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 ac7606d51a3d
children 5cd48568ec59
files doc/ChangeLog doc/interpreter/geometryimages.m doc/interpreter/interpimages.m doc/interpreter/plotimages.m doc/interpreter/sparseimages.m
diffstat 5 files changed, 65 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,14 @@
+2009-12-04  Rik <octave@nomad.inbox5.com>
+
+	* interpreter/geometryimages.m, interpreter/interpimages.m,
+	  interpreter/sparseimages.m, interpreter/plotimages.m: 
+	  Set default paperorientation to landscape to stop warning message
+
+2009-12-04  Ben Abbott <bpabbott@mac.com>
+
+	* interpreter/geometryimages.m, interpreter/interpimages.m,
+	  interpreter/sparseimages.m: Set default papersize to the desired imagesize
+
 2009-12-04  John W. Eaton  <jwe@octave.org>
 
 	* interpreter/images.awk: Emit rules to copy PNG files to
--- a/doc/interpreter/geometryimages.m
+++ b/doc/interpreter/geometryimages.m
@@ -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
--- a/doc/interpreter/interpimages.m
+++ b/doc/interpreter/interpimages.m
@@ -17,10 +17,12 @@
 ## <http://www.gnu.org/licenses/>.
 
 function interpimages (nm, typ)
-  bury_output ();
+  set_print_size ();
+  hide_output ();
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
   endif
+
   if (strcmp (typ, "txt"))
     image_as_txt (nm);
   elseif (strcmp (nm, "interpft"))
@@ -66,13 +68,22 @@
     legend('spline','pchip');
     print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
   endif
-  bury_output ();  
+  hide_output ();  
+endfunction
+
+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
--- a/doc/interpreter/plotimages.m
+++ b/doc/interpreter/plotimages.m
@@ -23,6 +23,7 @@
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
   endif
+
   if (strcmp(typ , "txt"))
     image_as_txt(nm);
   elseif (strcmp (nm, "plot"))
@@ -77,10 +78,14 @@
   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 hide_output ()
   f = figure (1);
   set (f, "visible", "off");
--- a/doc/interpreter/sparseimages.m
+++ b/doc/interpreter/sparseimages.m
@@ -17,6 +17,7 @@
 ## <http://www.gnu.org/licenses/>.
 
 function sparseimages (nm, typ)
+  set_print_size ();
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
   endif
@@ -40,19 +41,28 @@
   endif
 endfunction
 
-function bury_output ()
+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
+
+function hide_output ()
   f = figure (1);
   set (f, "visible", "off");
 endfunction
 
 function gplotimages (nm, typ)
-  bury_output ();
+  hide_output ();
   A = sparse ([2,6,1,3,2,4,3,5,4,6,1,5],
 	      [1,1,2,2,3,3,4,4,5,5,6,6], 1, 6, 6);
   xy = [0,4,8,6,4,2;5,0,5,7,5,7]';
   gplot (A, xy)
   print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
-  bury_output ();
+  hide_output ();
 endfunction
 
 function txtimages(nm,n,typ)
@@ -83,14 +93,14 @@
 endfunction
 
 function otherimages(nm,n,typ)
-  bury_output ();
+  hide_output ();
   a = 10*speye(n) + sparse(1:n,ceil([1:n]/2),1,n,n) + ...
       sparse(ceil([1:n]/2),1:n,1,n,n);
   if (strcmp (nm, "spmatrix"))
     spy(a);
     axis("ij")
     print(cstrcat("spmatrix.",typ),cstrcat("-d",typ))
-    bury_output ();
+    hide_output ();
   else
     if (!isempty(findstr(octave_config_info ("DEFS"),"HAVE_COLAMD")) &&
 	!isempty(findstr(octave_config_info ("DEFS"),"HAVE_CHOLMOD")))
@@ -99,13 +109,13 @@
 	spy(r1);
 	axis("ij")
 	print(cstrcat("spchol.",typ),cstrcat("-d",typ))
-	bury_output ();
+	hide_output ();
       elseif (strcmp (nm, "spcholperm"))
 	[r2,p2,q2]=chol(a);
 	spy(r2);
 	axis("ij")
 	print(cstrcat("spcholperm.",typ),cstrcat("-d",typ))
-	bury_output ();
+	hide_output ();
       endif
       ## printf("Image NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2));
     endif
@@ -151,7 +161,7 @@
 endfunction
 
 function femimages (nm,typ)
-  bury_output ();
+  hide_output ();
   if (!isempty(findstr(octave_config_info ("DEFS"),"HAVE_COLAMD")) &&
       !isempty(findstr(octave_config_info ("DEFS"),"HAVE_CHOLMOD")) &&
       !isempty(findstr(octave_config_info ("DEFS"),"HAVE_UMFPACK")))
@@ -228,7 +238,7 @@
     plot3 (xelems, yelems, velems);
     view (10, 10);
     print(cstrcat(nm,".",typ),cstrcat("-d",typ))
-    bury_output ();
+    hide_output ();
   endif
 endfunction
 
@@ -247,7 +257,7 @@
     return;
   else ## if (!strcmp (typ, "txt"))
 
-    bury_output ();
+    hide_output ();
 
     x = y = linspace (-8, 8, 41)';
     [xx, yy] = meshgrid (x, y);
@@ -258,7 +268,7 @@
       title ("Sorry, graphics not available because octave was\\ncompiled without the sparse matrix implementation.");
     unwind_protect_cleanup
       print (cstrcat (nm, ".", typ), cstrcat ("-d", typ));
-      bury_output ();
+      hide_output ();
     end_unwind_protect
   endif
 endfunction