On Wed, Jan 19, 2011 at 9:16 AM, Nicholas Devenish <
misnomer+matplot...@gmail.com <misnomer%2bmatplot...@gmail.com>> wrote:
> Hi,
>
> I have a few questions on formatting axis labels, when using the
> ScalarFormatter class (which appears to be the basic standard).
>
> Firstly, is there a general method to change the font size of all
> labels on the axis, other than looping over them such as in:
> >>> [x.set_fontsize(10) for x in plt.gca().xaxis.get_ticklabels()]
>
If you have version 1.0.0 or later, you can use tick_params():
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.tick_params
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.tick_params
>
> Secondly, when displaying the power limits with very large numbers on
> the axis, how do you change the font size of the displayed power
> limit? it does not seem to be tied into the axis ticklabels lists, and
> I do not know how to access it.
>
>
Most likely, you are talking about the "offset text", which you can get
access to its Text object using:
ax.xaxis.get_offset_text() or ax.yaxis.get_offset_text()
> Lastly, some questions on the defaults: The documentation mentions
> that the default power limits were changed from (-3, 4) to (-7, 7).
> I'm curious as to the reasoning for this, because 10^7 seems an
> excessively large number of digits and altogether a much worse
> default. In addition, the fact that using math text for the exponent
> is turned off by default (displaying 1e3 instead of the much more
> appropriate $10^3$) is also puzzling. In relation to this exponential
> display, is there a better way to turn it on, on an existing plot,
> other than the (seemingly undocumented):
> >>> plt.gca().yaxis.get_major_formatter()._useMathText=True
>
>
I can't comment on the change of the default range of values (that happened
before I joined). However, there are two ways to get the nice MathText
formatting of tick labels. One, you can change the axis scale to log:
ax.set_xscale('log') or ax.set_yscale('log')
Or (if you don't want log scale), you can explicitly pass in a
ScalarFormatter object with MathText turned on:
http://matplotlib.sourceforge.net/api/ticker_api.html#matplotlib.ticker.ScalarFormatter
niceMathTextForm = ScalarFormatter(useMathText=True)
ax.xaxis.set_major_formatter( niceMathTextForm )
I hope that helps!
Ben Root
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users