8000 FIX: formatting in LogFormatterExponent by tacaswell · Pull Request #5594 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: formatting in LogFormatterExponent #5594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 14, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MNT: clean up exponents in simpler way
Makes sure that there are never trailing 'e' with no exponent.
  • Loading branch information
tacaswell committed Dec 1, 2015
commit 7566447ca969181e18c9990a2137af4bfb4c4163
10 changes: 6 additions & 4 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,13 +731,15 @@ def pprint_val(self, x, d):
else:
fmt = '%1.3f'
s = fmt % x
#print d, x, fmt, s

tup = s.split('e')
if len(tup) == 2:
mantissa = tup[0].rstrip('0').rstrip('.')
sign = tup[1][0].replace('+', '')
exponent = tup[1][1:].lstrip('0')
s = '%se%s%s' % (mantissa, sign, exponent)
exponent = int(tup[1])
if exponent:
s = '%se%d' % (mantissa, exponent)
else:
s = mantissa
else:
s = s.rstrip('0').rstrip('.')
return s
Expand Down
0