ps backend, when usetex=True, uses latex with psfrag package to
generate the output (with some extra steps).
It seems that the bounding box information is not correctly recovered
during this process.
I first thought that it would be quite difficult to get this correct,
however the attached (relatively simple) patch seems to work fine.

Ken, can you try the patch and see if it works?

-JJ




On Thu, Apr 23, 2009 at 2:25 PM, Ken Schutte <kts.li...@gmail.com> wrote:
> I've been trying to track down some strange behavior I was getting,
> and I think narrowed it down to some code that I'll paste below.
>
> I'm trying to write to .eps files, and when I have usetex=True,
> something is screwed up with the padding on the left, and eventually
> the whole image is just white.
>
> If I run this script, the 'testA-*.eps' look good, but 'testB-*' does
> not.  The same problem happens even if I remove the ticklabels.
>
> Any tips would be appreciated.
> thanks,
> Ken
>
>
>
> ------------------------------------------------
> import matplotlib.pyplot as plt
> import numpy as np
> from matplotlib import rc
>
> fig = plt.figure()
> ax = fig.add_axes([0,0,1,1],frameon=False)
>
> X = np.tile(np.arange(500),(10,1))  # (10,500) shape
>
> ax.imshow(X,interpolation='nearest',aspect='auto')
>
> def go(name):
>
>    for d in (1,2,3,4):
>
>        w = d*5
>        h = d
>
>        fig.set_size_inches(w,h)
>        fig.savefig("%s-%d.eps" % (name,d))
>
> rc('text', usetex=False)
> go("testA")
>
> rc('text', usetex=True)
> go("testB")
>
> ------------------------------------------------------------------------------
> Crystal Reports &#45; New Free Runtime and 30 Day Trial
> Check out the new simplified licensign option that enables unlimited
> royalty&#45;free distribution of the report engine for externally facing
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
Index: lib/matplotlib/backends/backend_ps.py
===================================================================
--- lib/matplotlib/backends/backend_ps.py	(revision 7061)
+++ lib/matplotlib/backends/backend_ps.py	(working copy)
@@ -1096,17 +1096,22 @@
             isLandscape = True
             width, height = height, width
             bbox = (lly, llx, ury, urx)
-        temp_papertype = _get_papertype(width, height)
-        if papertype=='auto':
-            papertype = temp_papertype
-            paperWidth, paperHeight = papersize[temp_papertype]
+
+        if isEPSF:
+            paperWidth, paperHeight = self.figure.get_size_inches()
         else:
-            paperWidth, paperHeight = papersize[papertype]
-            if (width>paperWidth or height>paperHeight) and isEPSF:
+            temp_papertype = _get_papertype(width, height)
+            if papertype=='auto':
+                papertype = temp_papertype
                 paperWidth, paperHeight = papersize[temp_papertype]
-                verbose.report('Your figure is too big to fit on %s paper. %s \
-paper will be used to prevent clipping.'%(papertype, temp_papertype), 'helpful')
+            else:
+                paperWidth, paperHeight = papersize[papertype]
+                if (width>paperWidth or height>paperHeight) and isEPSF:
+                    paperWidth, paperHeight = papersize[temp_papertype]
+                    verbose.report('Your figure is too big to fit on %s paper. %s \
+    paper will be used to prevent clipping.'%(papertype, temp_papertype), 'helpful')
 
+
         texmanager = renderer.get_texmanager()
         font_preamble = texmanager.get_font_preamble()
         custom_preamble = texmanager.get_custom_preamble()
@@ -1247,8 +1252,8 @@
     os.remove(outfile)
     os.remove(tmpfile)
     shutil.move(psfile, tmpfile)
-    if eps:
-        pstoeps(tmpfile, bbox)
+    #if eps:
+    #    pstoeps(tmpfile, bbox)
 
 
 def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None):
------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to