From: Darren D. <dd...@co...> - 2005-12-06 19:29:21
|
On Tuesday 06 December 2005 10:03, Christian Kristukat wrote: > Darren Dale wrote: > > On Tuesday 06 December 2005 09:10, Alex Gontmakher wrote: > >>Hi, > >> > >>I'm trying to use matplotlib solely for my plotting needs. > >>Problem is, the fonts are embedded in each EPS file, and > >>when I import several plots (I have tens of them...) into a > >>single Latex, the resulting file is HUGE. > >> > >>Any suggestions? > > > > There are currently two options: you can either set ps.useafm = True, or > > you can set text.usetex = True in your rc settings. Since you are > > importing figures into latex, I suggest the usetex option. That way, your > > figure fonts can be the same as your text fonts. You'll take a bit of a > > speed hit with the latter option, but in my opinion, its the only way to > > go for generating plots for publication. > > When using tex for font rendering I noticed that parts of the text are not > converted to polygons but embedded as bitmaps. That makes the files big > again. Do you now how to avoid that? E.g. using the r'$C_{12}$ will produce > two images for the numbers and a polygon for the 'C'. I made a wiki entry a while back about how to work around this problem, but it looks like someone deleted it in mid-November, and I dont have a backup copy. My solution requires ghostview and xpdf, which is why we dont include it in mpl by default. You can remove the following block in backend_ps.py, starting around line 1144: command = 'latex -interaction=nonstopmode "%s"' % texfile verbose.report(command, 'debug-annoying') stdin, stdout, stderr = os.popen3(command) verbose.report(stdout.read(), 'debug-annoying') verbose.report(stderr.read(), 'helpful') command = 'dvips -R -T %fin,%fin -o "%s" "%s"' % (pw, ph, psfile, dvifile) verbose.report(command, 'debug-annoying') stdin, stdout, stderr = os.popen3(command) verbose.report(stdout.read(), 'debug-annoying') verbose.report(stderr.read(), 'helpful') os.remove(epsfile) if ext.startswith('.ep'): dpi = rcParams['ps.distiller.res'] if sys.platform == 'win32': command = 'gswin32c -dBATCH -dNOPAUSE -dSAFER -r%d \ -sDEVICE=epswrite -dLanguageLevel=2 -dEPSFitPage \ -sOutputFile="%s" "%s"'% (dpi, epsfile, psfile) else: command = 'gs -dBATCH -dNOPAUSE -dSAFER -r%d \ -sDEVICE=epswrite -dLanguageLevel=2 -dEPSFitPage \ -sOutputFile="%s" "%s"'% (dpi, epsfile, psfile) verbose.report(command, 'debug-annoying') stdin, stdout, stderr = os.popen3(command) verbose.report(stdout.read(), 'debug-annoying') verbose.report(stderr.read(), 'helpful') shutil.move(epsfile, outfile) else: shutil.move(psfile, outfile) and replace it with this: command = 'latex -interaction=nonstopmode "%s"' % texfile verbose.report(command, 'debug-annoying') stdin, stdout, stderr = os.popen3(command) verbose.report(stdout.read(), 'debug-annoying') verbose.report(stderr.read(), 'helpful') command = 'dvips -R -T %fin,%fin -o "%s" "%s"' % (pw, ph, psfile, dvifile) verbose.report(command, 'debug-annoying') stdin, stdout, stderr = os.popen3(command) verbose.report(stdout.read(), 'debug-annoying') verbose.report(stderr.read(), 'helpful') os.remove(epsfile) pdffile = tmpname + '.pdf' if ext.startswith('.ep'): command = 'ps2pdf "%s"'% psfile os.system(command) command = 'pdftops -level2 "%s" "%s"'% (pdffile, psfile) os.system(command) os.remove(pdffile) command = '/usr/local/bin/ps2eps -l "%s"'% psfile stdin, stderr = os.popen4(command) verbose.report(stderr.read(), 'helpful') command = 'epstopdf "%s"'% epsfile os.system(command) shutil.move(epsfile, outfile) shutil.move(pdffile, basename+'.pdf') else: command = 'ps2pdf "%s" "%s"'% (psfile, pdffile) stdin, stderr = os.popen4(command) verbose.report(stderr.read(), 'helpful') os.remove(psfile) command = 'pdftops -paperw %d -paperh %d -level2 "%s" "%s"'% \ (int(pw*72), int(ph*72), pdffile, psfile) os.system(command) shutil.move(psfile, outfile) Darren |