|
From: <ef...@us...> - 2010-04-18 23:11:30
|
Revision: 8241
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8241&view=rev
Author: efiring
Date: 2010-04-18 23:11:24 +0000 (Sun, 18 Apr 2010)
Log Message:
-----------
Improve access to ScalarFormatter useOffset and offset parameters
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/boilerplate.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/pyplot.py
trunk/matplotlib/lib/matplotlib/ticker.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2010-04-17 13:45:13 UTC (rev 8240)
+++ trunk/matplotlib/CHANGELOG 2010-04-18 23:11:24 UTC (rev 8241)
@@ -1,3 +1,6 @@
+2010-04-18 Control ScalarFormatter offsets directly and via the
+ Axes.ticklabel_format() method, and add that to pyplot. -EF
+
2010-04-16 Add a close_event to the backends. -RM
2010-04-06 modify axes_grid examples to use axes_grid1 and axisartist. -JJL
Modified: trunk/matplotlib/boilerplate.py
===================================================================
--- trunk/matplotlib/boilerplate.py 2010-04-17 13:45:13 UTC (rev 8240)
+++ trunk/matplotlib/boilerplate.py 2010-04-18 23:11:24 UTC (rev 8241)
@@ -101,6 +101,7 @@
'table',
'text',
'annotate',
+ 'ticklabel_format',
)
cmappable = {
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2010-04-17 13:45:13 UTC (rev 8240)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2010-04-18 23:11:24 UTC (rev 8241)
@@ -1880,6 +1880,11 @@
be used for numbers outside the range
10`-m`:sup: to 10`n`:sup:.
Use (0,0) to include all numbers.
+ *useOffset* [True | False | offset]; if True,
+ the offset will be calculated as needed;
+ if False, no offset will be used; if a
+ numeric offset is specified, it will be
+ used.
*axis* [ 'x' | 'y' | 'both' ]
============ =====================================
@@ -1892,13 +1897,14 @@
"""
style = kwargs.pop('style', '').lower()
scilimits = kwargs.pop('scilimits', None)
+ useOffset = kwargs.pop('useOffset', None)
+ axis = kwargs.pop('axis', 'both').lower()
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
elif style in ['plain', 'comma']:
@@ -1923,6 +1929,11 @@
self.xaxis.major.formatter.set_powerlimits(scilimits)
if axis == 'both' or axis == 'y':
self.yaxis.major.formatter.set_powerlimits(scilimits)
+ if useOffset is not None:
+ if axis == 'both' or axis == 'x':
+ self.xaxis.major.formatter.set_useOffset(useOffset)
+ if axis == 'both' or axis == 'y':
+ self.yaxis.major.formatter.set_useOffset(useOffset)
except AttributeError:
raise AttributeError(
"This method only works with the ScalarFormatter.")
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2010-04-17 13:45:13 UTC (rev 8240)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2010-04-18 23:11:24 UTC (rev 8241)
@@ -2529,6 +2529,14 @@
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
+@docstring.copy_dedent(Axes.ticklabel_format)
+def ticklabel_format(**kwargs):
+ ret = gca().ticklabel_format(**kwargs)
+ draw_if_interactive()
+ return ret
+
+# This function was autogenerated by boilerplate.py. Do not edit as
+# changes will be lost
def autumn():
'''
set the default colormap to autumn and apply to current image if any.
Modified: trunk/matplotlib/lib/matplotlib/ticker.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/ticker.py 2010-04-17 13:45:13 UTC (rev 8240)
+++ trunk/matplotlib/lib/matplotlib/ticker.py 2010-04-18 23:11:24 UTC (rev 8241)
@@ -321,22 +321,34 @@
data < 10^-n or data >= 10^m, where n and m are the power limits set using
set_powerlimits((n,m)). The defaults for these are controlled by the
axes.formatter.limits rc parameter.
+
"""
def __init__(self, useOffset=True, useMathText=False):
# useOffset allows plotting small data ranges with large offsets:
# for example: [1+1e-9,1+2e-9,1+3e-9]
# useMathText will render the offset and scientific notation in mathtext
- self._useOffset = useOffset
+ self.set_useOffset(useOffset)
self._usetex = rcParams['text.usetex']
self._useMathText = useMathText
- self.offset = 0
self.orderOfMagnitude = 0
self.format = ''
self._scientific = True
self._powerlimits = rcParams['axes.formatter.limits']
+ def get_useOffset(self):
+ return self._useOffset
+ def set_useOffset(self, val):
+ if val in [True, False]:
+ self.offset = 0
+ self._useOffset = val
+ else:
+ self._useOffset = False
+ self.offset = val
+
+ useOffset = property(fget=get_useOffset, fset=set_useOffset)
+
def fix_minus(self, s):
'use a unicode minus rather than hyphen'
if rcParams['text.usetex'] or not rcParams['axes.unicode_minus']: return s
@@ -412,7 +424,8 @@
if len(self.locs) > 0:
vmin, vmax = self.axis.get_view_interval()
d = abs(vmax-vmin)
- if self._useOffset: self._set_offset(d)
+ if self._useOffset:
+ self._set_offset(d)
self._set_orderOfMagnitude(d)
self._set_format()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|