@@ -294,6 +294,13 @@ def _set_locator(self, locator):
294
294
""" Subclasses may want to override this to set a locator. """
295
295
pass
296
296
297
+ @cbook .deprecated ("3.1" )
298
+ def pprint_val (self , * args , ** kwargs ):
299
+ return self ._pprint_val (* args , ** kwargs )
300
+
301
+ def _pprint_val (self , * args , ** kwargs ):
302
+ raise NotImplementedError
303
+
297
304
298
305
class IndexFormatter (Formatter ):
299
306
"""
@@ -428,22 +435,19 @@ class OldScalarFormatter(Formatter):
428
435
429
436
def __call__ (self , x , pos = None ):
430
437
"""
431
- Return the format for tick val `x` based on the width of the
432
- axis.
438
+ Return the format for tick val `x` based on the width of the axis.
433
439
434
440
The position `pos` is ignored.
435
441
"""
436
442
xmin , xmax = self .axis .get_view_interval ()
437
443
d = abs (xmax - xmin )
444
+ return self ._pprint_val (x , d )
438
445
439
- return self .pprint_val (x , d )
440
-
441
- def pprint_val (self , x , d ):
446
+ def _pprint_val (self , x , d ):
442
447
"""
443
448
Formats the value `x` based on the size of the axis range `d`.
444
449
"""
445
- #if the number is not too big and it's an int, format it as an
446
- #int
450
+ # If the number is not too big and it's an int, format it as an int.
447
451
if abs (x ) < 1e4 and x == int (x ):
448
452
return '%d' % x
449
453
@@ -555,7 +559,7 @@ def __call__(self, x, pos=None):
555
559
if len (self .locs ) == 0 :
556
560
return ''
557
561
else :
558
- s = self .pprint_val (x )
562
+ s = self ._pprint_val (x )
559
563
return self .fix_minus (s )
560
564
561
565
def set_scientific (self , b ):
@@ -766,7 +770,7 @@ def _set_format(self, vmin, vmax):
766
770
elif self ._useMathText :
767
771
self .format = '$%s$' % _mathdefault (self .format )
768
772
769
- def pprint_val (self , x ):
773
+ def _pprint_val (self , x ):
770
774
xp = (x - self .offset ) / (10. ** self .orderOfMagnitude )
771
775
if np .abs (xp ) < 1e-8 :
772
776
xp = 0
@@ -966,7 +970,7 @@ def _num_to_string(self, x, vmin, vmax):
966
970
elif x < 1 :
967
971
s = '%1.0e' % x
968
972
else :
969
- s = self .pprint_val (x , vmax - vmin )
973
+ s = self ._pprint_val (x , vmax - vmin )
970
974
return s
971
975
972
976
def __call__ (self , x , pos = None ):
@@ -1007,9 +1011,8 @@ def format_data_short(self, value):
1007
1011
"""
1008
1012
return '%-12g' % value
1009
1013
1010
- def pprint_val (self , x , d ):
1011
- #if the number is not too big and it's an int, format it as an
1012
- #int
1014
+ def _pprint_val (self , x , d ):
1015
+ # If the number is not too big and it's an int, format it as an int.
1013
1016
if abs (x ) < 1e4 and x == int (x ):
1014
1017
return '%d' % x
1015
1018
@@ -1052,7 +1055,7 @@ def _num_to_string(self, x, vmin, vmax):
1052
1055
s = '%1.0g' % fx
1053
1056
else :
1054
1057
fd = math .log (vmax - vmin ) / math .log (self ._base )
1055
- s = self .pprint_val (fx , fd )
1058
+ s = self ._pprint_val (fx , fd )
1056
1059
return s
1057
1060
1058
1061
0 commit comments