@@ -1432,13 +1432,16 @@ def __call__(self, x, pos=None):
1432
1432
if len (self .locs ) == 0 or self .offset == 0 :
1433
1433
return self .fix_minus (self .format_data (x ))
1434
1434
else :
1435
- xp = (x - self .offset ) / (10. ** self .orderOfMagnitude )
1435
+ # Here in ScalarFormatter.__call__ we also check
1436
+ # self.orderOfMagnitude. In this class, it is always 0, since the
1437
+ # oom of the data is represented by the ENG_PREFIXES prepending
1438
+ # the ticks.
1439
+ xp = x - self .offset
1436
1440
if abs (xp ) < 1e-8 :
1437
1441
xp = 0
1438
- # The ScalarFormatter.__call__ reads the locale here as well. We
1439
- # don't care about it, and we want the ticks to also get the unit
1440
- # with the best prefix as computed by self.format_data that is
1441
- # produced by it doesn't.
1442
+ # Also in contrary to ScalarFormatter.__call__ we use the
1443
+ # conditioned tex formatting provided by self.format_data and we
1444
+ # don't care about the locale.
1442
1445
return self .fix_minus (self .format_data (xp ))
1443
1446
1444
1447
def set_locs (self , locs ):
@@ -1447,41 +1450,21 @@ def set_locs(self, locs):
1447
1450
if len (self .locs ) > 0 :
1448
1451
if self ._useOffset :
1449
1452
self ._compute_offset ()
1450
- self ._set_order_of_magnitude ()
1451
- # This is what's different from ScalarFormatter: We search among
1452
- # the engineers' standard orders of magnitudes (0, -3, 3, -6, 6,
1453
- # -9, 9 etc) the oom closest to our self.orderOfMagnitude. Then we
1454
- # set our self.orderOfMagnitude to it.
1455
- c = abs (self .orderOfMagnitude )
1456
- for sciOom in itertools .count (0 , 3 ):
1457
- if c <= sciOom :
1458
- self .orderOfMagnitude = math .copysign (sciOom , self .orderOfMagnitude )
1459
- break
1460
- self ._set_format ()
1461
1453
1462
1454
# Simplify a bit ScalarFormatter.get_offset: We always want to use
1463
- # self.format_data. We insert here the surrounding $...$ here, if tex /
1464
- # mathtext is set.
1455
+ # self.format_data, and we don't need to handle tex related features as
1456
+ # these are handled well by self.format_data. Also we don't need to check
1457
+ # self.orderOfMagnitude since we want it to always be 0, because the ticks
1458
+ # themselves represetnt the order of magnitude of the data much better.
1465
1459
def get_offset (self ):
1466
1460
# docstring inherited
1467
1461
if len (self .locs ) == 0 :
1468
1462
return ''
1469
- if self .orderOfMagnitude or self .offset :
1470
- offsetStr = ''
1471
- sciNotStr = ''
1472
- if self .offset :
1473
- offsetStr = self .format_data (self .offset )
1474
- if self .offset > 0 :
1475
- offsetStr = '+' + offsetStr
1476
- if self .orderOfMagnitude :
1477
- sciNotStr = self .format_data (10 ** self .orderOfMagnitude )
1478
- if self ._useMathText or self ._usetex :
1479
- if sciNotStr != '' :
1480
- sciNotStr = r'\times%s' % sciNotStr
1481
- s = fr'${ sciNotStr } { offsetStr } $'
1482
- else :
1483
- s = '' .join ((sciNotStr , offsetStr ))
1484
- return self .fix_minus (s )
1463
+ if self .offset :
1464
+ offsetStr = self .format_data (self .offset )
1465
+ if self .offset > 0 :
1466
+ offsetStr = '+' + offsetStr
1467
+ return self .fix_minus (offsetStr )
1485
1468
return ''
1486
1469
1487
1470
def format_eng (self , num ):
0 commit comments