Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c39af7e

Browse files
committed
Minor tweaks to the new scalar formatter: changed formatting for "0", fixed
two floating point inaccuracy problems. svn path=/trunk/matplotlib/; revision=1271
1 parent 82e1cb4 commit c39af7e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lib/matplotlib/ticker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ def _set_offset(self, range):
304304
ave_oom = math.floor(math.log10(absolute(ave_loc)))
305305
range_oom = math.floor(math.log10(range))
306306
if absolute(ave_oom-range_oom) >= 4: # four sig-figs
307-
if ave_loc < 0: self.offset = math.ceil(amax(locs)/10**range_oom)*10**range_oom
308-
else: self.offset = math.floor(amin(locs)/10**range_oom)*10**range_oom
307+
if ave_loc < 0:
308+
self.offset = math.ceil(average(locs)/10**range_oom)*10**range_oom
309+
else:
310+
self.offset = math.floor(average(locs)/10**range_oom)*10**range_oom
309311
else: self.offset = 0
310312

311313
def _set_orderOfMagnitude(self,range):
@@ -333,8 +335,8 @@ def _set_format(self):
333335

334336
def pprint_val(self, x):
335337
xp = (x-self.offset)/10**self.orderOfMagnitude
336-
if closeto(xp,0): return '0'
337-
else: return self.format % xp
338+
if absolute(xp) < 1e-8: xp = 0
339+
return self.format % xp
338340

339341
def _formatSciNotation(self,s,mathtext=False):
340342
# transform 1e+004 into 1e4, for example

0 commit comments

Comments
 (0)