8000 BUG: Whoops. Will squash this. · matplotlib/matplotlib@a6c2775 · GitHub
[go: up one dir, main page]

Skip to content

Commit a6c2775

Browse files
committed
BUG: Whoops. Will squash this.
1 parent fbb8eb4 commit a6c2775

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lib/matplotlib/ticker.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ def __call__(self, x, pos=None):
10171017
xmin, xmax = self.axis.get_view_interval()
10181018
d = abs(xmax - xmin)
10191019

1020-
return self.fix_minus(format_pct(x, d))
1020+
return self.fix_minus(self.format_pct(x, d))
10211021

10221022
def format_pct(self, x, d):
10231023
"""
@@ -1046,16 +1046,19 @@ def format_pct(self, x, d):
10461046
"""
10471047
x = self.convert_to_pct(x)
10481048
if self.decimals is None:
1049-
# Luckily Python's built-in `ceil` rounds to +inf, not away
1050-
# from zero. This is very important since the equation for
1051-
# `decimals` starts out as `d > 0.5 * 10**(2 - decimals)`
1052-
# and ends up with `decimals > 2 - log10(2 * d)`.
1053-
d = self.convert_to_pct(d) # d is a difference, so this works
1054-
decimals = math.ceil(2.0 - math.log10(2.0 * d))
1055-
if decimals > 5:
1056-
decimals = 5
1057-
elif decimals < 0:
1049+
if d <= 0:
10581050
decimals = 0
1051+
else:
1052+
# Luckily Python's built-in `ceil` rounds to +inf, not away
1053+
# from zero. This is very important since the equation for
1054+
# `decimals` starts out as `d > 0.5 * 10**(2 - decimals)`
1055+
# and ends up with `decimals > 2 - log10(2 * d)`.
1056+
d = self.convert_to_pct(d) # d is a difference, so this works
1057+
decimals = math.ceil(2.0 - math.log10(2.0 * d))
1058+
if decimals > 5:
1059+
decimals = 5
1060+
elif decimals < 0:
1061+
decimals = 0
10591062
else:
10601063
decimals = self.decimals
10611064
s = '{x:0.{decimals}f}'.format(x=x, decimals=int(decimals))

0 commit comments

Comments
 (0)
0