Skip to content

Commit 9121205

Browse files
committed
FIX: force format_eng(-0.0) to be consistent with format_eng(0)
1 parent 43d812d commit 9121205

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

12751279
pow10 = pow10.min(max(self.ENG_PREFIXES))
12761280
pow10 = pow10.max(min(self.ENG_PREFIXES))

0 commit comments

Comments
 (0)