# Problem/Bug with Text rendering With LaTeX

Hi,

mpl is a great package. Thanks for the effort first!

Recently I have tried to use latex to render all the texts in a plot for consistent look with other texts in a paper. However, it seems that all the texts in the plot are rendered in bold font. Please see the attached code.

···

==

#!/opt/local/bin/python

from matplotlib.pyplot import *

from matplotlib import rc

rc(‘text’, usetex=True)

rc(‘font’, family=‘serif’)

text(.1, .2, r’first $f(x,y)=x+y\ \mathrm{first}\ \mathbf{first}\ \textrm{first}\ \textnormal{first}$’)

xlabel(r’first $f(x,y)=x+y\ \mathrm{first}\ \mathbf{first}\ \textrm{first}\ \textnormal{first}$’)

savefig(‘test_tex.pdf’, transparent=True)

==

The text in 1) normal environment (quoted in r’text’), 2) in \textrm{}, 3) \textnormal{} are the same with 4) \mathbf{}. The only way to produce with “normal” font is to put the text in \mathrm{}.

The matplotlibrc is default or blank. I was able to reproduce the result with versions 1.1.0 and 1.1.1 on both linux and mac. And I couldn’t find a quick fix from the internet.

Furthermore, I found that the texts in the tutorial page http://matplotlib.sourceforge.net/users/usetex.html are also bolded: “TeX is Number …” is thicker than the font in the following equation and the tics labels, whose “normal” font can be seen by putting them in \mathrm{}.

It is quite annoying to have inconsistent font in the figure and the main texts. Could someone look into it? Thanks a million!

A Spherical Chicken

Can you try with the following setup?

params = {'backend': 'Agg',
'ps.usedistiller' : 'xpdf',
'text.usetex' : True,
'font.family': 'serif',
'font.serif' : ['Times'],
}
mpl.rcParams.update(params)

I made all the figures in this paper using these parameters:
http://arxiv.org/pdf/1110.5063v1

Alejandro

···

On Sun, May 20, 2012 at 4:14 PM, Yang Zhang <a.spherical.chicken@...287...> wrote:

Recently I have tried to use latex to render all the texts in a plot for
consistent look with other texts in a paper. However, it seems that all the
texts in the plot are rendered in bold font. Please see the attached code.

Hi Alejandro,

Thank you very much for your help! It is a font priority problem. I added cmr to the first of font.serif. Problem solved!

rcParams[‘font.serif’] = [‘Computer Modern Roman’] + rcParams[‘font.serif’]

Many thanks again!

A Spherical Chicken

···

On Sun, May 20, 2012 at 6:55 PM, Alejandro Weinstein <alejandro.weinstein@…287…> wrote:

On Sun, May 20, 2012 at 4:14 PM, Yang Zhang > > <a.spherical.chicken@…878…287…> wrote:

Recently I have tried to use latex to render all the texts in a plot for

consistent look with other texts in a paper. However, it seems that all the

texts in the plot are rendered in bold font. Please see the attached code.

Can you try with the following setup?

params = {‘backend’: ‘Agg’,

     'ps.usedistiller' : 'xpdf',

'text.usetex' : True,

'font.family': 'serif',

'font.serif' : ['Times'],

}


mpl.rcParams.update(params)

I made all the figures in this paper using these parameters:

http://arxiv.org/pdf/1110.5063v1

Alejandro