Skip to content

Commit fd130c1

Browse files
committed
make sure only one zero label is returned
1 parent b8364c6 commit fd130c1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/matplotlib/ticker.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ class LogFormatterMathtext(LogFormatter):
10631063
"""
10641064
Format values for log axis using ``exponent = log_base(value)``.
10651065
"""
1066+
_min_zero_pos = None
10661067

10671068
def _non_decade_format(self, sign_string, base, fx, usetex):
10681069
'Return string for non-decade locations'
@@ -1076,16 +1077,21 @@ def __call__(self, x, pos=None):
10761077
"""
10771078
Return the format for tick value `x`.
10781079
1079-
The position `pos` is ignored.
1080+
The position `pos` is used for SymLogNorm for ensuring
1081+
only one zero entry is present.
10801082
"""
10811083
usetex = rcParams['text.usetex']
10821084
min_exp = rcParams['axes.formatter.min_exponent']
10831085

10841086
if x == 0: # Symlog
1085-
if usetex:
1086-
return '$0$'
1087+
if self._min_zero_pos is None:
1088+
self._min_zero_pos = pos
1089+
if usetex:
1090+
return '$0$'
1091+
else:
1092+
return '$%s$' % _mathdefault('0')
10871093
else:
1088-
return '$%s$' % _mathdefault('0')
1094+
return ''
10891095

10901096
sign_string = '-' if x < 0 else ''
10911097
x = abs(x)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy