Skip to content
Closed
Changes from all commits
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
8 changes: 5 additions & 3 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ def pprint_val(self, x, d):
return s


SPECIAL_LOG = set((0, 0.1, 1, 10))

class LogFormatterExponent(LogFormatter):
"""
Format values for log axis; using ``exponent = log_base(value)``
Expand Down Expand Up @@ -776,11 +778,11 @@ def __call__(self, x, pos=None):
usetex = rcParams['text.usetex']

# only label the decades
if x == 0:
if x in SPECIAL_LOG:
if usetex:
return '$0$'
return '${0:g}$'.format(x)
else:
return '$\mathdefault{0}$'
return '$\mathdefault{{{0:g}}}$'.format(x)

fx = math.log(abs(x)) / math.log(b)
is_decade = is_close_to_int(fx)
Expand Down