8000 Fix 999.9... edge case in ticker.EngFormatter for negative numbers · matplotlib/matplotlib@8e17289 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e17289

Browse files
authored
Fix 999.9... edge case in ticker.EngFormatter for negative numbers
1 parent 5e01393 commit 8e17289

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/matplotlib/ticker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,8 @@ def format_eng(self, num):
12681268
# Taking care of the cases like 999.9..., which may be rounded to 1000
12691269
# instead of 1 k. Beware of the corner case of values that are beyond
12701270
# the range of SI prefixes (i.e. > 'Y').
1271-
if float(format(mant, fmt)) >= 1000 and pow10 < max(self.ENG_PREFIXES):
1271+
_fmant = float(format(mant, fmt))
1272+
if (_fmant >= 1000 or _fmant <= -1000) and pow10 < max(self.ENG_PREFIXES):
12721273
mant /= 1000
12731274
pow10 += 3
12741275

0 commit comments

Comments
 (0)
0