From: <ef...@us...> - 2008-10-05 04:33:01
|
Revision: 6148 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6148&view=rev Author: efiring Date: 2008-10-05 04:32:52 +0000 (Sun, 05 Oct 2008) Log Message: ----------- Add scilimits kwarg to Axes.ticklabel_format() method Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-10-05 01:38:31 UTC (rev 6147) +++ trunk/matplotlib/CHANGELOG 2008-10-05 04:32:52 UTC (rev 6148) @@ -1,3 +1,7 @@ +2008-10-04 Added 'scilimits' kwarg to Axes.ticklabel_format() method, + for easy access to the set_powerlimits method of the + major ScalarFormatter. - EF + 2008-10-04 Experimental new kwarg borderpad to replace pad in legend, based on suggestion by Jae-Joon Lee. - EF Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-10-05 01:38:31 UTC (rev 6147) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-10-05 04:32:52 UTC (rev 6148) @@ -1639,26 +1639,34 @@ Optional keyword arguments: - ======= ===================================== - Keyword Description - ======= ===================================== - *style* [ 'sci' (or 'scientific') | 'plain' ] - plain turns off scientific notation - *axis* [ 'x' | 'y' | 'both' ] - ======= ===================================== + ============ ===================================== + Keyword Description + ============ ===================================== + *style* [ 'sci' (or 'scientific') | 'plain' ] + plain turns off scientific notation + *scilimits* (m, n), pair of integers; if *style* + is 'sci', scientific notation will + be used for numbers outside the range + 10`-m`:sup: to 10`n`:sup:. + Use (0,0) to include all numbers. + *axis* [ 'x' | 'y' | 'both' ] + ============ ===================================== Only the major ticks are affected. If the method is called when the :class:`~matplotlib.ticker.ScalarFormatter` is not the :class:`~matplotlib.ticker.Formatter` being used, an - :exc:`AttributeError` will be raised with no additional error - message. + :exc:`AttributeError` will be raised. - Additional capabilities and/or friendlier error checking may - be added. - """ style = kwargs.pop('style', '').lower() + scilimits = kwargs.pop('scilimits', None) + if scilimits is not None: + try: + m, n = scilimits + m+n+1 # check that both are numbers + except (ValueError, TypeError): + raise ValueError("scilimits must be a sequence of 2 integers") axis = kwargs.pop('axis', 'both').lower() if style[:3] == 'sci': sb = True @@ -1673,11 +1681,20 @@ sb = None else: raise ValueError, "%s is not a valid style value" - if sb is not None: - if axis == 'both' or axis == 'x': - self.xaxis.major.formatter.set_scientific(sb) - if axis == 'both' or axis == 'y': - self.yaxis.major.formatter.set_scientific(sb) + try: + if sb is not None: + if axis == 'both' or axis == 'x': + self.xaxis.major.formatter.set_scientific(sb) + if axis == 'both' or axis == 'y': + self.yaxis.major.formatter.set_scientific(sb) + if scilimits is not None: + if axis == 'both' or axis == 'x': + self.xaxis.major.formatter.set_powerlimits(scilimits) + if axis == 'both' or axis == 'y': + self.yaxis.major.formatter.set_powerlimits(scilimits) + except AttributeError: + raise AttributeError( + "This method only works with the ScalarFormatter.") def set_axis_off(self): """turn off the axis""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |