changeset 9056:b06dc393ac42

print.m: For eps output the bounding box should represent the figure's position.
author Ben Abbott <bpabbott@mac.com>
date Sun, 29 Mar 2009 00:32:01 -0400
parents 8651fcc89556
children 8b263623d0f3
files scripts/ChangeLog scripts/plot/print.m
diffstat 2 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-29  Ben Abbott <bpabbott@mac.com>
+
+	* plot/print.m: For eps output the bounding box should represent the
+	figure's position.
+
 2009-03-28  Ben Abbott <bpabbott@mac.com>
 
 	* plot/gnuplot_drawnow.m: Always set figure property "__plot_stream__"
--- a/scripts/plot/print.m
+++ b/scripts/plot/print.m
@@ -428,19 +428,26 @@
     set (gcf, "__pixels_per_inch__", resolution)
 
     unwind_protect
-      if (! isempty (size))
-        size_in_pixels = sscanf (size ,"%d, %d");
-        size_in_pixels = reshape (size_in_pixels, [1, numel(size_in_pixels)]);
-        size_in_inches = size_in_pixels ./ resolution;
+      if (! isempty (size) || any (strfind (dev, "eps") == 1))
         p.paperunits = get (gcf, "paperunits");
         p.papertype = get (gcf, "papertype");
         p.papersize = get (gcf, "papersize");
         p.paperposition = get (gcf, "paperposition");
         p.paperpositionmode = get (gcf, "paperpositionmode");
         set (gcf, "paperunits", "inches");
+        if (any (strfind (dev, "eps") == 1))
+          paperposition_in_inches = get (gcf, "paperposition") + 1/72;
+          paperposition_in_inches(1:2) = 0;
+          papersize_in_inches = paperposition_in_inches(3:4);
+        else
+          size_in_pixels = sscanf (size ,"%d, %d");
+          size_in_pixels = reshape (size_in_pixels, [1, numel(size_in_pixels)]);
+          papersize_in_inches = size_in_pixels ./ resolution;
+          paperposition_in_inches = [0, 0, papersize_in_inches];
+        endif
         set (gcf, "papertype", "<custom>");
-        set (gcf, "papersize", size_in_inches);
-        set (gcf, "paperposition", [0, 0, size_in_inches]);
+        set (gcf, "papersize", papersize_in_inches);
+        set (gcf, "paperposition", paperposition_in_inches);
         set (gcf, "paperpositionmode", "manual");
       endif
       if (debug)
@@ -449,8 +456,8 @@
         drawnow (new_terminal, name, mono);
       endif
     unwind_protect_cleanup
-      ## FIXME - it would be preferred to delete the added properties here.
-      if (! isempty (size))
+      ## FIXME - it would be nice to delete "__pixels_per_inch__" property here.
+      if (! isempty (size) || any (strfind (dev, "eps") == 1))
         props = fieldnames (p);
         for n = 1:numel(props)
           set (gcf, props{n}, p.(props{n}))