On Tue, Sep 29, 2009 at 12:53 AM, Christopher Barrington-Leigh <cpblpublic+nab...@gmail.com> wrote: > > > > Jae-Joon Lee wrote: >> >> Hmm, I'm afraid that this only works if you use preview mode. I >> haven't tested, but I guess it will fail without it. Check if >> rcParams["text.latex.preview"]==True. >> > > Hm, I don't know about mpl's mathtext mode, but I'm actually always > working in usetex mode. Unfortunately, even so, > "text.latex.preview" does not exist in rcParams for me. However,... : > > I think the following behaviour is definitely > buggy! Please try the following one at a time, in ion() mode (or just see > sequence of png's produced). None of these succeeds in getting the desired > alignment. > > > from matplotlib import rc > > figure(1) > clf() > plot([0,0],[1,1]) > > rc('text', usetex=True) > > text(xlim()[1],.96,r'$r^2$~~~\mbox{}',horizontalalignment='right') > savefig('t10.png')
This works if you use recent version of matplotlib with preview mode on. Without the preview mode (or other similar ways to report the dimension of the text from TeX side), I don't think this can be done. > > rc('text', usetex=False) > show() > savefig('t20.png') > > text(xlim()[1],.97,r'$r^2$~~~\mbox{}',horizontalalignment='right') > savefig('t30.png') > This does not. First of all, "~" and "\mbox" are not supported if usetex=False and I guess never will be. On the other hand, as far as I can see, the whitespace stripping is not done in mpl side. And I have a feeling that it may be the freetype library. mpl uses FT_Glyph_Get_CBox to calculate the extents of the text and I think this seems to fail when there is a trailing spaces. This is beyond me I hope other developers have better idea. So, Christopher, I guess your best chance is to upgrade and use preview mode, or use annotate function. Regards, -JJ > rc('text', usetex=True) > > show() > savefig('t40.png') > > -- > View this message in context: > http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25656912.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users