File tree 1 file changed +5
-12
lines changed
1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -1001,13 +1001,7 @@ def set_locs(self, locs=None):
1001
1001
self ._sublabels = set (np .arange (1 , b + 1 ))
1002
1002
1003
1003
def _num_to_string (self , x , vmin , vmax ):
1004
- if x > 10000 :
1005
- s = '%1.0e' % x
1006
- elif x < 1 :
1007
- s = '%1.0e' % x
1008
- else :
1009
- s = self ._pprint_val (x , vmax - vmin )
1010
- return s
1004
+ return self ._pprint_val (x , vmax - vmin ) if 1 <= x <= 10000 else f"{ x :1.0e} "
1011
1005
1012
1006
def __call__ (self , x , pos = None ):
1013
1007
# docstring inherited
@@ -1067,15 +1061,14 @@ class LogFormatterExponent(LogFormatter):
1067
1061
"""
1068
1062
Format values for log axis using ``exponent = log_base(value)``.
1069
1063
"""
1064
+
1070
1065
def _num_to_string (self , x , vmin , vmax ):
1071
1066
fx = math .log (x ) / math .log (self ._base )
1072
- if abs (fx ) > 10000 :
1073
- s = '%1.0g' % fx
1074
- elif abs (fx ) < 1 :
1075
- s = '%1.0g' % fx
1076
- else :
1067
+ if 1 <= abs (fx ) <= 10000 :
1077
1068
fd = math .log (vmax - vmin ) / math .log (self ._base )
1078
1069
s = self ._pprint_val (fx , fd )
1070
+ else :
1071
+ s = f"{ fx :1.0g} "
1079
1072
return s
1080
1073
1081
1074
You can’t perform that action at this time.
0 commit comments