From: Humufr <hu...@ya...> - 2004-09-24 16:15:31
|
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. Another things I saw in the website, a lot of links are not working (example: http://matplotlib.sourceforge.net/figure.html#Axis ) Thanks, Nicolas |
From: John H. <jdh...@ac...> - 2004-09-24 16:38:41
|
>>>>> "Humufr" == Humufr <hu...@ya...> writes: Humufr> Hello, I would like to know how can I change the Humufr> axes properties for the font of the tick label. I was Humufr> trying to use something like: Humufr> xticklabels = get(gca(), 'xticklabels') set(xticklabels, Humufr> 'fontweight', 'bold') Humufr> and that's work for some parameter (fontweight for Humufr> example) but it's not possible to choose some others like Humufr> 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. Humufr> Another things I saw in the website, a lot of links are Humufr> not working (example: Humufr> http://matplotlib.sourceforge.net/figure.html#Axis\ ) That should be http://matplotlib.sourceforge.net/matplotlib.figure.html#Axis. I fixed this (in my local copy). Let me know if you find some more. JDH |
From: Humufr <hu...@ya...> - 2004-09-27 17:39:31
|
John Hunter wrote: >>>>>>"Humufr" == Humufr <hu...@ya...> writes: >>>>>> >>>>>> > > Humufr> Hello, I would like to know how can I change the > Humufr> axes properties for the font of the tick label. I was > Humufr> trying to use something like: > > Humufr> xticklabels = get(gca(), 'xticklabels') set(xticklabels, > Humufr> 'fontweight', 'bold') > > Humufr> and that's work for some parameter (fontweight for > Humufr> example) but it's not possible to choose some others like > Humufr> 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 |
From: John H. <jdh...@ac...> - 2004-09-29 21:17:55
|
>>>>> "Humufr" == Humufr <hu...@ya...> writes: Humufr> the different fonts available. I obtain: Humufr> ['Lucida Grande', 'Verdana', 'Geneva', 'Lucida', Humufr> 'Bitstream Vera Sans', 'Arial', 'Helvetica', 'sans-serif'] Humufr> but if I'm trying to use the font Arial and italic in the Humufr> script that give me this message: Could not match Humufr> sans-serif, italic, normal. Returning Humufr> /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf Humufr> It's seems that the change introduce in the script is not Humufr> use and that matplotlib are using only Vera fonts with no Humufr> style. Note that this list does not mean that these fonts are available on your system. They are simply the fonts that matplotlib will look for if you specify sans-serif. Humufr> fonts = { 'color' : 'k', 'fontname' : 'Courier', Humufr> 'fontweight' : 'bold', 'fontstyle' : 'italic', 'fontsize' Humufr> : 'xx-large' Humufr> } Humufr> ylabel('toto',fonts) Humufr> give me exactly the same things than: Humufr> fonts = { 'color' : 'k', 'fontname' : 'Arial, 'fontweight' Humufr> : 'bold', 'fontstyle' : 'italic', 'fontsize' : 'xx-large' Humufr> } Are you sure that you have Courier and Arial on your system and are they in your TTFPATH? If you are sure on both counts, it may help to remove your font cache (typically ~/.ttffont.cache on linux like systems) and let matplotlib regenerate it's cache. Those are my only ideas so far, let me know. JDH |
From: Humufr <hu...@ya...> - 2004-09-30 14:55:06
|
Hi John, this was the solution thanks. I was deleting the older .fonts.cache. I didn't notice the change, I'm apoligizing for the disturbance. Thanks again, Nicolas >Are you sure that you have Courier and Arial on your system and are >they in your TTFPATH? > >If you are sure on both counts, it may help to remove your font cache >(typically ~/.ttffont.cache on linux like systems) and let matplotlib >regenerate it's cache. > >Those are my only ideas so far, let me know. > >JDH > > > |