@@ -1063,6 +1063,7 @@ class LogFormatterMathtext(LogFormatter):
1063
1063
"""
1064
1064
Format values for log axis using ``exponent = log_base(value)``.
1065
1065
"""
1066
+ _min_zero_pos = None
1066
1067
1067
1068
def _non_decade_format (self , sign_string , base , fx , usetex ):
1068
1069
'Return string for non-decade locations'
@@ -1076,16 +1077,21 @@ def __call__(self, x, pos=None):
1076
1077
"""
1077
1078
Return the format for tick value `x`.
1078
1079
1079
- The position `pos` is ignored.
1080
+ The position `pos` is used for SymLogNorm for ensuring
1081
+ only one zero entry is present.
1080
1082
"""
1081
1083
usetex = rcParams ['text.usetex' ]
1082
1084
min_exp = rcParams ['axes.formatter.min_exponent' ]
1083
108
10000
5
1084
1086
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' )
1087
1093
else :
1088
- return '$%s$' % _mathdefault ( '0' )
1094
+ return ''
1089
1095
1090
1096
sign_string = '-' if x < 0 else ''
1091
1097
x = abs (x )
@@ -2315,7 +2321,7 @@ def get_log_range(lo, hi):
2315
2321
2316
2322
if has_c :
2317
2323
if has_b :
2318
- c_range = get_log_range (t , vmax + 1 )
2324
+ c_range = get_log_range (t , vmax + 1 ) # Why the +1?
2319
2325
else :
2320
2326
c_range = get_log_range (vmin , vmax + 1 )
2321
2327
else :
@@ -2346,7 +2352,10 @@ def get_log_range(lo, hi):
2346
2352
if len (subs ) > 1 or subs [0 ] != 1.0 :
2347
2353
ticklocs = []
2348
2354
for decade in decades :
2349
- ticklocs .extend (subs * decade )
2355
+ if decade == 0 :
2356
+ ticklocs .append (decade )
2357
+ else :
2358
+ ticklocs .extend (subs * decade )
2350
2359
else :
2351
2360
ticklocs = decades
2352
2361
0 commit comments