@@ -910,6 +910,7 @@ def pprint_val(self, x, d):
910
910
s = s .rstrip ('0' ).rstrip ('.' )
911
911
return s
912
912
913
+
913
914
class LogFormatterExponent (LogFormatter ):
914
915
"""
915
916
Format values for log axis using ``exponent = log_base(value)``.
@@ -999,6 +1000,7 @@ def __call__(self, x, pos=None):
999
1000
'%s%s^{%d}' %
1000
1001
(sign_string , base , nearest_long (fx ))))
1001
1002
1003
+
1002
1004
class LogFormatterSciNotation (LogFormatterMathtext ):
1003
1005
"""
1004
1006
Format values following scientific notation in a logarithmic axis
@@ -1022,6 +1024,7 @@ def _non_decade_format(self, sign_string, base, fx, usetex):
1022
1024
return (r'$\mathdefault{%g\times%s^{%d}}$' ) % \
1023
1025
(coeff , base , exponent )
1024
1026
1027
+
1025
1028
class LogitFormatter (Formatter ):
1026
1029
"""
1027
1030
Probability formatter (using Math text).
@@ -1932,22 +1935,20 @@ def show_tick_label(self, ticklocs):
1932
1935
numdec = abs (vmax - vmin )
1933
1936
1934
1937
if numdec > 3 :
1938
+ # Label only bases
1935
1939
sublabel = set ((1 ,))
1936
- elif numdec > 2 :
1937
- sublabel = set ((1 , 3 ))
1938
- elif numdec > 1 :
1939
- sublabel = set ((1 , 2 , 5 ))
1940
1940
else :
1941
- sublabel = set ((1 , 2 , 4 , 7 ))
1941
+ # Add labels between bases at log-spaced coefficients
1942
+ c = np .logspace (0 , 1 , (4 - int (numdec )) + 1 , base = b )
1943
+ sublabel = set (np .round (c ))
1942
1944
1943
- label = np .ones (ticklocs .size , dtype = np .bool )
1944
- for i , loc in enumerate (ticklocs ):
1945
- exponent = math .floor (math .log (abs (loc )) / math .log (b ))
1946
- coeff = loc / b ** nearest_long (exponent )
1947
- if nearest_long (coeff ) not in sublabel :
1948
- label [i ] = False
1945
+ fx = np .log (abs (ticklocs )) / np .log (b )
1946
+ exponents = np .array ([np .round (x ) if is_close_to_int (x )
1947
+ else np .floor (x )
1948
+ for x in fx ])
1949
+ coeffs = np .round (ticklocs / b ** exponents )
1949
1950
1950
- return label
1951
+ return [ c in sublabel for c in coeffs ]
1951
1952
1952
1953
def view_limits (self , vmin , vmax ):
1953
1954
'Try to choose the view limits intelligently'
0 commit comments