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