Skip to content

Commit 722f5d6

Browse files
committed
FIX: force format_eng(-0.0) to be consistent with format_eng(0)
1 parent 5a550f2 commit 722f5d6

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
@@ -1273,6 +1273,10 @@ def format_eng(self, num):
12731273
pow10 = decimal.Decimal(int(math.floor(dnum.log10() / 3) * 3))
12741274
else:
12751275
pow10 = decimal.Decimal(0)
1276+
# Force dnum to zero, to avoid inconsistencies like
1277+
# format_eng(-0) = "0" and format_eng(0.0) = "0"
1278+
# but format_eng(-0.0) = "-0.0"
1279+
dnum = decimal.Decimal(0)
12761280

12771281
pow10 = pow10.min(max(self.ENG_PREFIXES))
12781282
pow10 = pow10.max(min(self.ENG_PREFIXES))

0 commit comments

Comments
 (0)