John Hunter wrote:
"Humufr" == Humufr <humufr@...136...> writes:
> Hello, I would like to know how can I change the
> axes properties for the font of the tick label. I was
> trying to use something like:
> xticklabels = get(gca(), 'xticklabels') set(xticklabels,
> 'fontweight', 'bold')
> and that's work for some parameter (fontweight for
> example) but it's not possible to choose some others like
> the font type or the angle.
You need to pick the right property names: rotation rather than angle,
fontname or family for the fontname or family
from matplotlib.matlab import *
plot([1,2,3])
labels = get(gca(), 'xticklabels')
set(labels, fontweight='bold', rotation=45, fontname='cmr10')
show()
You may want to read http://matplotlib.sourceforge.net/fonts.html and
the fonts section in the rc file to decide if you want to use the
family or fontname property.
I think one of the reasons you may be having problem with the fontname
is that matplotlib appears to fail silently when you specify a font
that it doesn't find. In this case, it falls back on a known font.
We hope to add a verbose feature so you can get some diagnostic
information about what the font finder is doing.
Hi,
Thanks for your answer, I have been able to change the font but the things I don't like, no that I think it's not coherent with other matplotlib command is that in the font you can't ask fontname=Courier" and fontstyle="Italic" (the term angle was bad in my precedent mail ). That doesn't work.
Perhaps it's a problem with my installation (debian and package from this distribution and Suse and matplotlib install by hand) but I have an error message when I'm trying to have some Italic. I wa trying to use the script:
http://matplotlib.sourceforge.net/examples/fonts_demo.py
and I have this message when the script want plot the italic fonts:
Could not match cursive, normal, normal. Returning /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
Could not match fantasy, normal, normal. Returning /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
Could not match sans-serif, italic, normal. Returning /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
Could not match sans-serif, italic, normal. Returning /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
Could not match sans-serif, italic, normal. Returning /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
I defined the TTFPATH and I have no change.
I have something else weird with the fonts. I verified i=with Ipython and
from matplotlib.font_manager import fontManager, FontProperties
from matplotlib.matlab import *
p = FontProperties()
p.get_family()
the different fonts available. I obtain:
['Lucida Grande',
'Verdana',
'Geneva',
'Lucida',
'Bitstream Vera Sans',
'Arial',
'Helvetica',
'sans-serif']
but if I'm trying to use the font Arial and italic in the script that give me this message:
Could not match sans-serif, italic, normal. Returning /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
It's seems that the change introduce in the script is not use and that matplotlib are using only Vera fonts with no style.
fonts = {
'color' : 'k',
'fontname' : 'Courier',
'fontweight' : 'bold',
'fontstyle' : 'italic',
'fontsize' : 'xx-large'
}
ylabel('toto',fonts)
give me exactly the same things than:
fonts = {
'color' : 'k',
'fontname' : 'Arial,
'fontweight' : 'bold',
'fontstyle' : 'italic',
'fontsize' : 'xx-large'
}
ylabel('toto',fonts)
The only things that seems to work is the fontweigth.
I have exactly the same things if I'm doing:
t = ylabel('label')
set(t,'fontstyle','italic')
I did probably something wrong but I can't find where so I'm asking for some help,
Nicolas