Hi all,
I'm enjoying the new toy (real LaTeX support), and after running the examples/tex_demo, I noticed the bounding boxes aren't quite right. I know that Darren and John have struggled a lot with this issue, and I don't know what the true solution should be. But I've seen similar problems in the past with Gnuplot (when making square aspect ratio plots), and I had this lying around:
def eps_fix_bbox(fname):
"""Fix the bounding box of an eps file by running ps2eps on it.
If its name ends in .eps, the original file is removed.
This is particularly useful for plots made by Gnuplot with square aspect
ratio: there is a bug in Gnuplot which makes it generate a bounding box
which is far wider than the actual plot.
This function assumes that ps2eps is installed in your system."""
# note: ps2ps and eps2eps do NOT work, ONLY ps2eps works correctly. The
# others make output with bitmapped fonts, which looks horrible.
print 'Fixing eps file: <%s>' % fname
xsys('ps2eps -f -q -l %s' % fname)
if fname.endswith('.eps'):
os.rename(fname+'.eps',fname)
those of you running IPython can get it simply via:
from IPython.Gnuplot2 import eps_fix_bbox
I don't claim that it does the right thing everywhere, but a few tests seemed to give reasonable results. I don't know if it will help others, but it works for me, so here it goes.
Cheers,
f