@@ -1432,13 +1432,16 @@ def __call__(self, x, pos=None):
14321432 if len (self .locs ) == 0 or self .offset == 0 :
14331433 return self .fix_minus (self .format_data (x ))
14341434 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
14361440 if abs (xp ) < 1e-8 :
14371441 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.
14421445 return self .fix_minus (self .format_data (xp ))
14431446
14441447 def set_locs (self , locs ):
@@ -1447,41 +1450,21 @@ def set_locs(self, locs):
14471450 if len (self .locs ) > 0 :
14481451 if self ._useOffset :
14491452 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 ()
14611453
14621454 # 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.
14651459 def get_offset (self ):
14661460 # docstring inherited
14671461 if len (self .locs ) == 0 :
14681462 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 )
14851468 return ''
14861469
14871470 def format_eng (self , num ):
0 commit comments