Pierre,
Offhand, it looks like it should go into ticker.py, so I will probably
do that.
Eric
Pierre GM wrote:
> On Monday 18 December 2006 13:29, David L Goldsmith wrote:
>> Simson Garfinkel wrote:
>>> It really depends on your audience as to whether or not 1,000,000
>>> through 9,000,000 is better displayed in scientific notation or not.
>>> For audiences that I frequently present to, any scientific notation
>>> is just unacceptable. You can add quantifiers (like KBps, MBps,
>>> GBps), but presenting something a 5e+5 Bps will just be lost. You
>>> *might* get away with e+3, e+6, and e+9, but never the other e's.
>> Ah, "Engineering" notation - that could be a useful helper function.
>
> A few months ago the question got asked on this very list.
> The idea is to define a specific formatter. Here's what I'd come with (I copy
> the initial post for convenience at the end of the message).
>
> If it's found useful, I could put it in the cookbook (now that I remember how
> to edit the wiki). Or I could leave our dear developers add it to the core.
>
>
> P.
>
> #----------------------------------------------
>
> 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, mrange):
> """Sets the order of margnitude."""
> locs = N.absolute(self.locs)
> if self.offset:
> oom = math.floor(math.log10(mrange))
> else:
> if locs[0] > locs[-1]:
> val = locs[0]
> else:
> val = locs[-1]
> if val == 0:
> oom = 0
> else:
> oom = math.floor(math.log10(val))
> if oom <= -3:
> self.orderOfMagnitude = 3*(oom//3)
> elif oom <= -1:
> self.orderOfMagnitude = -3
> elif oom >= 4:
> self.orderOfMagnitude = 3*(oom//3)
> else:
> self.orderOfMagnitude = 0
> #........................
> def _set_format(self):
> """Sets the format string to format all ticklabels."""
> # set the format string to format all the ticklabels
> locs = (N.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
> #..............................................................................
> class MinimalFormatter(Formatter):
> """A minimal formatter: just the plain data !"""
> def __init__(self,sigfigs=None):
> if sigfigs is None:
> self.fmt = "%f"
> else:
> self.fmt = "%.%if" % sigfigs
> def __call__(self,x,pos=None):
> return str(self.fmt % x).rstrip('0')
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users