From: John H. <jdh...@ac...> - 2005-05-27 17:32:31
|
>>>>> "Meesters," == Meesters, Christian <mee...@un...> writes: Meesters> Hi, It's me again ... I still do not find my way out of Meesters> the problem on how I can apply a format to the Meesters> numbering of an axis. I am using the WXAgg backend and Meesters> this is my code: To apply a "default font" for the entire figure, you can use the rc params -- see http://matplotlib.sf.net/.matplotlibrc, especially the font.*, axes.* and tick.* settings from matplotlib import rc from pylab import figure, show rc('font', weight='bold', style='italics') rc('axes', labelsize=25) rc('tick', labelsize=14) fig = figure() ax = fig.add_subplot(111) ax.plot(range(10)) ax.set_xlabel('hi') ax.set_ylabel('bye') ax.set_title('easy as 1-2-3') show() You can also customize the default tick labels sizes individually. I already noted that for the xlabel, ylabel and title you can use kwargs, eg ax.set_xlabel('hi', fontsize='smaller') and so on. For the tick labels, you will need to get a list of the tick label Text instances you want to customize labels = ax.get_xticklabels() You can call any of the text setter methods on these labels, which are detailed here http://matplotlib.sourceforge.net/matplotlib.text.html#Text For example, you can set the fontsize or fontproperty with for label in labels: label.set_fontsize(mysize) for label in labels: label.set_fontproperties(fp) A lot of the methods like set_fontsize are historical artifacts from before we had font properties, and they just forward the call to the property If you want finer grained control over the major and minor ticks, or different customizations for the top and bottom ticks (on the xaxis the top ticks are normally off but you can turn them on) you can do that too, but it is a little more work # ditto for get_minor_ticks ticks = ax.xaxis.get_major_ticks() majLabelsLower = [tick.label1 for tick in ticks] majLabelsUpper = [tick.label2 for tick in ticks] and then call the setter methods on these as above. Hope this helps, JDH |