Skip to content

Commit 0f37c41

Browse files
committed
FIX: force format_eng(-0.0) to be consistent with format_eng(0)
1 parent 99b590c commit 0f37c41

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/ticker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,10 @@ def format_eng(self, num):
11171117
pow10 = decimal.Decimal(int(math.floor(dnum.log10() / 3) * 3))
11181118
else:
11191119
pow10 = decimal.Decimal(0)
1120+
# Force dnum to zero, to avoid inconsistencies like
1121+
# format_eng(-0) = "0" and format_eng(0.0) = "0"
1122+
# but format_eng(-0.0) = "-0.0"
1123+
dnum = decimal.Decimal(0)
11201124

11211125
pow10 = pow10.min(max(self.ENG_PREFIXES.keys()))
11221126
pow10 = pow10.max(min(self.ENG_PREFIXES.keys()))

0 commit comments

Comments
 (0)