From: John H. <jd...@gm...> - 2008-09-15 12:56:49
|
On Mon, Sep 15, 2008 at 7:13 AM, sa6113 <s.p...@gm...> wrote: > > I think I have to explain it more clear, I want to show a fontdialog to the > user contain font name, style, size and some effect, and user will be able > select all these changes for legend and axis labels separately, then I want > to effect these items to my plot as you know user has very different options > and it will be difficult to use font's path. > > Is that possible to set all those options are selected by user in fontdialog > box to the plot?? > > If it is. How? I would be thankful if you help me. Yes, this is easily doable. The fond obj command works on any matplotlib instance, so for example, if you wanted to selectively change the text properties of the xaxis:: # see matplotlib.text.Text for information about the settable properties at # http://matplotlib.sourceforge.net/doc/html/api/artist_api.html#matplotlib.text.Text for t in ax.xaxis.findobj(text.Text): t.set_fontstyle('something') t.set_fontsize(12) for the legend you would do the same::: leg = ax.get_legend() for t in leg.findobj(text.Text): # set some properties here All the text setters just forward the calls onto the FontProperties object (see matplotlib.font_manager.FontProperties) so take a look at this object to see what is available. Eg, from my previous post, you can set the fontname explicitly with:: prop.set_file('somefile.ttf') JDH |