Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b6901fa

Browse filesBrowse files
authored
Merge pull request matplotlib#13324 from anntzer/scalarformatter
Cleanup ScalarFormatter; preparatory to moving it to format_ticks.
2 parents 68e8d95 + ea0552e commit b6901fa
Copy full SHA for b6901fa

File tree

Expand file treeCollapse file tree

1 file changed

+6
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-11
lines changed

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+6-11Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -650,18 +650,13 @@ def set_locs(self, locs):
650650
"""
651651
self.locs = locs
652652
if len(self.locs) > 0:
653-
vmin, vmax = self.axis.get_view_interval()
654-
d = abs(vmax - vmin)
655653
if self._useOffset:
656654
self._compute_offset()
657-
self._set_orderOfMagnitude(d)
658-
self._set_format(vmin, vmax)
655+
self._set_order_of_magnitude()
656+
self._set_format()
659657

660658
def _compute_offset(self):
661659
locs = self.locs
662-
if locs is None or not len(locs):
663-
self.offset = 0
664-
return
665660
# Restrict to visible ticks.
666661
vmin, vmax = sorted(self.axis.get_view_interval())
667662
locs = np.asarray(locs)
@@ -699,7 +694,7 @@ def _compute_offset(self):
699694
if abs_max // 10 ** oom >= 10**n
700695
else 0)
701696

702-
def _set_orderOfMagnitude(self, range):
697+
def _set_order_of_magnitude(self):
703698
# if scientific notation is to be used, find the appropriate exponent
704699
# if using an numerical offset, find the exponent after applying the
705700
# offset. When lower power limit = upper <> 0, use provided exponent.
@@ -719,7 +714,7 @@ def _set_orderOfMagnitude(self, range):
719714
self.orderOfMagnitude = 0
720715
return
721716
if self.offset:
722-
oom = math.floor(math.log10(range))
717+
oom = math.floor(math.log10(vmax - vmin))
723718
else:
724719
if locs[0] > locs[-1]:
725720
val = locs[0]
@@ -736,11 +731,11 @@ def _set_orderOfMagnitude(self, range):
736731
else:
737732
self.orderOfMagnitude = 0
738733

739-
def _set_format(self, vmin, vmax):
734+
def _set_format(self):
740735
# set the format string to format all the ticklabels
741736
if len(self.locs) < 2:
742737
# Temporarily augment the locations with the axis end points.
743-
_locs = [*self.locs, vmin, vmax]
738+
_locs = [*self.locs, *self.axis.get_view_interval()]
744739
else:
745740
_locs = self.locs
746741
locs = (np.asarray(_locs) - self.offset) / 10. ** self.orderOfMagnitude

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.