Skip to content

Commit 7585cd6

Browse files
authored
Merge pull request #20542 from anntzer/sfft
Fix ScalarFormatter.format_ticks for non-ordered tick locations.
2 parents 430041f + cc19764 commit 7585cd6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/matplotlib/tests/test_contour.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,13 @@ def test_contour_line_start_on_corner_edge():
464464
cbar = fig.colorbar(filled)
465465
lines = ax.contour(x, y, z, corner_mask=True, colors='k')
466466
cbar.add_lines(lines)
467+
468+
469+
@pytest.mark.style("default")
470+
def test_contour_autolabel_beyond_powerlimits():
471+
ax = plt.figure().add_subplot()
472+
cs = plt.contour(np.geomspace(1e-6, 1e-4, 100).reshape(10, 10),
473+
levels=[.25e-5, 1e-5, 4e-5])
474+
ax.clabel(cs)
475+
# Currently, the exponent is missing, but that may be fixed in the future.
476+
assert {text.get_text() for text in ax.texts} == {"0.25", "1.00", "4.00"}

lib/matplotlib/ticker.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,10 +817,7 @@ def _set_order_of_magnitude(self):
817817
if self.offset:
818818
oom = math.floor(math.log10(vmax - vmin))
819819
else:
820-
if locs[0] > locs[-1]:
821-
val = locs[0]
822-
else:
823-
val = locs[-1]
820+
val = locs.max()
824821
if val == 0:
825822
oom = 0
826823
else:

0 commit comments

Comments
 (0)