@@ -650,18 +650,13 @@ def set_locs(self, locs):
650
650
"""
651
651
self .locs = locs
652
652
if len (self .locs ) > 0 :
653
- vmin , vmax = self .axis .get_view_interval ()
654
- d = abs (vmax - vmin )
655
653
if self ._useOffset :
656
654
self ._compute_offset ()
657
- self ._set_orderOfMagnitude ( d )
658
- self ._set_format (vmin , vmax )
655
+ self ._set_order_of_magnitude ( )
656
+ self ._set_format ()
659
657
660
658
def _compute_offset (self ):
661
659
locs = self .locs
662
- if locs is None or not len (locs ):
663
- self .offset = 0
664
- return
665
660
# Restrict to visible ticks.
666
661
vmin , vmax = sorted (self .axis .get_view_interval ())
667
662
locs = np .asarray (locs )
@@ -699,7 +694,7 @@ def _compute_offset(self):
699
694
if abs_max // 10 ** oom >= 10 ** n
700
695
else 0 )
701
696
702
- def _set_orderOfMagnitude (self , range ):
697
+ def _set_order_of_magnitude (self ):
703
698
# if scientific notation is to be used, find the appropriate exponent
704
699
# if using an numerical offset, find the exponent after applying the
705
700
# offset. When lower power limit = upper <> 0, use provided exponent.
@@ -719,7 +714,7 @@ def _set_orderOfMagnitude(self, range):
719
714
self .orderOfMagnitude = 0
720
715
return
721
716
if self .offset :
722
- oom = math .floor (math .log10 (range ))
717
+ oom = math .floor (math .log10 (vmax - vmin ))
723
718
else :
724
719
if locs [0 ] > locs [- 1 ]:
725
720
val = locs [0 ]
@@ -736,11 +731,11 @@ def _set_orderOfMagnitude(self, range):
736
731
else :
737
732
self .orderOfMagnitude = 0
738
733
739
- def _set_format (self , vmin , vmax ):
734
+ def _set_format (self ):
740
735
# set the format string to format all the ticklabels
741
736
if len (self .locs ) < 2 :
742
737
# Temporarily augment the locations with the axis end points.
743
- _locs = [* self .locs , vmin , vmax ]
738
+ _locs = [* self .locs , * self . axis . get_view_interval () ]
744
739
else :
745
740
_locs = self .locs
746
741
locs = (np .asarray (_locs ) - self .offset ) / 10. ** self .orderOfMagnitude
0 commit comments