Darren,

> As of svn 2560, the label will render over the left or right y-axis
> depending on the position of the ticks.

Sweet ! Thanks a lot !

And following your advice, I came up with the following solution to my problem 
(forcing the mantissa to multiple of 3, with a given number of decimals). 
Should I post it on the wiki ?

Cheers, and thx again
Pierre


#------------------------------------------------------------------------------
class EngrFormatter(ScalarFormatter):
    """A variation of the standard ScalarFormatter, using only multiples of 
three in the mantissa. A fixed number of decimals can be displayed with the 
optional parameter `ndec` . If `ndec` is None (default), the number of 
decimals is defined from the current ticks.
    """
    def __init__(self, ndec=None, useOffset=True, useMathText=False):
        ScalarFormatter.__init__(self, useOffset, useMathText)
        if ndec is None or ndec < 0:
            self.format = None
        elif ndec == 0:
            self.format = "%d"
        else:
            self.format = "%%1.%if" % ndec

    def _set_orderOfMagnitude(self,range):
        ScalarFormatter._set_orderOfMagnitude(self,range)
        self.orderOfMagnitude = 3*(self.orderOfMagnitude//3)

    def _set_format(self):
        # set the format string to format all the ticklabels
        locs = (array(self.locs)-self.offset) / 
10**self.orderOfMagnitude+1e-15
        sigfigs = [len(str('%1.3f'% loc).split('.')[1].rstrip('0')) \
                   for loc in locs]
        sigfigs.sort()
        if self.format is None:
            self.format = '%1.' + str(sigfigs[-1]) + 'f'
        if self._usetex or self._useMathText: self.format = '$%s$'%self.format


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to