Hey everyone, this is more a how-to / feature request than a question... Normally, my workflow for embedding images in LaTeX is as follows:
1) produce ps-file 2) use pstoedit (xfig) to separate text/math (LaTeX-typesettable) from the image 3) save as pdf_t and pdf, respectively 4) \input this in the LaTeX document -- pdflatex will then set the text at every compilation. This has the advantage that I can change fonts etc without having to redo all the figures. I was trying to do so with matplotlib 0.98.3 and pstoedit 3.45 on a 64bit Ubuntu 8.10. I followed the instructions in the matplotlib cookbook but kept experiencing problems when calling pstoedit [1], the xlabels and ylabels were somehow converted to Courier but not put in the "text" part, "." would become ":" and so on. Solution brought this thread http://www.nabble.com/Switching-between-different-font-settings-ts21279388.html which suggested using OldScalarFormatter (thanks at this point also from my side, Jouni) -- which works, see attached example. So much for the "how-to-part" -- obviously, my suggestion is now to not force users to have math-labels. I have to admit that I am not aware of the drawbacks of OldScalarFormatter, but alone the name makes me think that it might be not the best solution... Thanks and best regards, Sebastian. P.S.: why actually does ax.yaxis.get_ticklabels()[1].get_text() return an empty string when called before savefig? P.P.S.: I expect to be offline several days, so please excuse me if I won't be answering timely. [1] pstoedit: version 3.45 / DLL interface 108 (build Jun 17 2008 - release build - g++ 4.3.1) : Copyright (C) 1993 - 2007 Wolfgang Glunz Warning: Level 2 version of image and imagemask not supported for this backend (due to lack of support for bitmaps on intermediate files) Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font MCSZLR+CMMI12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font MCSZLR+CMMI12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font MCSZLR+CMMI12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font MCSZLR+CMMI12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead. Warning, unsupported font MCSZLR+CMMI12, using Courier instead. Warning, unsupported font YBFHZA+CMR12, using Courier instead.
from matplotlib import rcParams params = {'backend': 'ps', 'ps.usedistiller': 'xpdf', 'text.usetex': True, } rcParams.update(params) from matplotlib.ticker import OldScalarFormatter import pylab from pylab import arange,pi,sin,cos,sqrt # Generate data x = pylab.arange(-2*pi,2*pi,0.01) y1 = sin(x) y2 = cos(x) # Plot data pylab.figure(1) pylab.clf() pylab.axes([0.125,0.2,0.95-0.125,0.95-0.2]) pylab.plot(x,y1,'g:',label='1sin(x)') pylab.plot(x,y2,'-b',label='cos(x)') pylab.xlabel('x (radians)') pylab.ylabel('y') pylab.legend() ax = pylab.gca() ax.xaxis.set_major_formatter(OldScalarFormatter()) ax.yaxis.set_major_formatter(OldScalarFormatter()) pylab.savefig('tex_demo.ps')
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users