@@ -545,7 +545,7 @@ def __call__(self, x, pos=None):
545
545
sign = np .sign (x )
546
546
# only label the decades
547
547
fx = math .log (abs (x ))/ math .log (b )
548
- isDecade = self . is_decade (fx )
548
+ isDecade = is_decade (fx )
549
549
if not isDecade and self .labelOnlyBase : s = ''
550
550
elif x > 10000 : s = '%1.0e' % x
551
551
elif x < 1 : s = '%1.0e' % x
@@ -566,15 +566,6 @@ def format_data_short(self,value):
566
566
'return a short formatted string representation of a number'
567
567
return '%-12g' % value
568
568
569
- def is_decade (self , x ):
570
- n = self .nearest_long (x )
571
- return abs (x - n )< 1e-10
572
-
573
- def nearest_long (self , x ):
574
- if x == 0 : return 0L
575
- elif x > 0 : return long (x + 0.5 )
576
- else : return long (x - 0.5 )
577
-
578
569
def pprint_val (self , x , d ):
579
570
#if the number is not too big and it's an int, format it as an
580
571
#int
@@ -616,7 +607,7 @@ def __call__(self, x, pos=None):
616
607
sign = np .sign (x )
617
608
# only label the decades
618
609
fx = math .log (abs (x ))/ math .log (b )
619
- isDecade = self . is_decade (fx )
610
+ isDecade = is_decade (fx )
620
611
if not isDecade and self .labelOnlyBase : s = ''
621
612
#if 0: pass
622
613
elif fx > 10000 : s = '%1.0e' % fx
@@ -643,7 +634,7 @@ def __call__(self, x, pos=None):
643
634
return '$0$'
644
635
sign = np .sign (x )
645
636
fx = math .log (abs (x ))/ math .log (b )
646
- isDecade = self . is_decade (fx )
637
+ isDecade = is_decade (fx )
647
638
648
639
usetex = rcParams ['text.usetex' ]
649
640
@@ -660,10 +651,10 @@ def __call__(self, x, pos=None):
660
651
s = '$\mathdefault{%s%d^{%.2f}}$' % (sign_string , b , fx )
661
652
else :
662
653
if usetex :
663
- s = r'$%s%d^{%d}$' % (sign_string , b , self . nearest_long (fx ))
654
+ s = r'$%s%d^{%d}$' % (sign_string , b , nearest_long (fx ))
664
655
else :
665
656
s = r'$\mathdefault{%s%d^{%d}}$' % (sign_string , b ,
666
- self . nearest_long (fx ))
657
+ nearest_long (fx ))
667
658
668
659
return s
669
660
@@ -1189,11 +1180,16 @@ def decade_up(x, base=10):
1189
1180
lx = np .ceil (np .log (x )/ np .log (base ))
1190
1181
return base ** lx
1191
1182
1192
- def is_decade (x ,base = 10 ):
1183
+ def nearest_long (x ):
1184
+ if x == 0 : return 0L
1185
+ elif x > 0 : return long (x + 0.5 )
1186
+ else : return long (x - 0.5 )
1187
+
1188
+ def is_decade (x , base = 10 ):
1193
1189
if x == 0.0 :
1194
1190
return True
1195
1191
lx = np .log (x )/ np .log (base )
1196
- return lx == int (lx )
1192
+ return abs ( lx - nearest_long (lx )) < 1e-10
1197
1193
1198
1194
class LogLocator (Locator ):
1199
1195
"""
@@ -1211,7 +1207,7 @@ def __init__(self, base=10.0, subs=[1.0], numdecs=4):
1211
1207
1212
1208
def base (self ,base ):
1213
1209
"""
1214
- set the base of the log scaling (major tick every base**i, i interger )
1210
+ set the base of the log scaling (major tick every base**i, i integer )
1215
1211
"""
1216
1212
self ._base = base + 0.0
1217
1213
0 commit comments