legend font weight with TeX

Hello,

I am using pylab with the rc parameter
rcParams[‘text.usetex’]=True

Now, I would like to make a legend with bold fonts.
So, I tried two options:

from matplotlib.font_manager import fontManager, FontProperties

font= FontProperties(weight=‘bold’,size=26)
plot([1,2,3],[1,2,3],‘k’,label=‘label1’)
legend(loc=‘lower left’, prop=font)

  1. After the legend(loc=‘lower left’, prop=font) statement, I put:

legend1=gca().get_legend()
ltext = legend1.get_texts() # all the text.Text instance in the legend
setp(ltext, fontweight=‘bold’) # the legend text fontsize

Neither of these options changed the legend font weight to bold.

How can this be done?
How to change the legend font weight when rcParams[‘text.usetex’]=True ?

Thanks,
Eli

I think you may have to do something like "label=r'\textbf{label1}'".

···

On Tue, Apr 5, 2011 at 2:51 PM, Eli Brosh <ebrosh1@...287...> wrote:

Hello,

I am using pylab with the rc parameter
rcParams['text.usetex']=True

Now, I would like to make a legend with bold fonts.
So, I tried two options:

1)
from matplotlib.font_manager import fontManager, FontProperties
font= FontProperties(weight='bold',size=26)
plot([1,2,3],[1,2,3],'k',label='label1')
legend(loc='lower left', prop=font)

2) After the legend(loc='lower left', prop=font) statement, I put:
legend1=gca().get_legend()
ltext = legend1.get_texts() # all the text.Text instance in the legend
setp(ltext, fontweight='bold') # the legend text fontsize

Neither of these options changed the legend font weight to bold.
How can this be done?
How to change the legend font weight when rcParams['text.usetex']=True ?

Thanks,
label=r’\bf{label1}
worked.

Regards,
Eli

···

On Tue, Apr 5, 2011 at 10:14 PM, Darren Dale <dsdale24@…287…> wrote:

On Tue, Apr 5, 2011 at 2:51 PM, Eli Brosh <ebrosh1@…287…> wrote:

Hello,

I am using pylab with the rc parameter

rcParams[‘text.usetex’]=True

Now, I would like to make a legend with bold fonts.

So, I tried two options:

from matplotlib.font_manager import fontManager, FontProperties

font= FontProperties(weight=‘bold’,size=26)

plot([1,2,3],[1,2,3],‘k’,label=‘label1’)

legend(loc=‘lower left’, prop=font)

  1. After the legend(loc=‘lower left’, prop=font) statement, I put:

legend1=gca().get_legend()

ltext = legend1.get_texts() # all the text.Text instance in the legend

setp(ltext, fontweight=‘bold’) # the legend text fontsize

Neither of these options changed the legend font weight to bold.

How can this be done?

How to change the legend font weight when rcParams[‘text.usetex’]=True ?

I think you may have to do something like “label=r’\textbf{label1}'”.