Skip to content

FIX: resolve an issue where no ticks would be drawn for a colorbar with SymLogNorm and ranging exactly from 0 to linthresh #25970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/matplotlib/tests/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,19 @@ def test_set_params(self):
assert sym._subs == [2.0]
assert sym.numticks == 8

@pytest.mark.parametrize(
'vmin, vmax, expected',
[
(0, 1, [0, 1]),
(-1, 1, [-1, 0, 1]),
],
)
def test_values(self, vmin, vmax, expected):
# https://github.com/matplotlib/matplotlib/issues/25945
sym = mticker.SymmetricalLogLocator(base=10, linthresh=1)
ticks = sym.tick_values(vmin=vmin, vmax=vmax)
assert_array_equal(ticks, expected)


class TestAsinhLocator:
def test_init(self):
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2496,11 +2496,11 @@ def tick_values(self, vmin, vmax):
# We could also add ticks at t, but that seems to usually be
# uninteresting.
#
# "simple" mode is when the range falls entirely within (-t,
# t) -- it should just display (vmin, 0, vmax)
if -linthresh < vmin < vmax < linthresh:
# "simple" mode is when the range falls entirely within [-t, t]
# -- it should just display (vmin, 0, vmax)
if -linthresh <= vmin < vmax <= linthresh:
# only the linear range is present
return [vmin, vmax]
return sorted({vmin, 0, vmax})

# Lower log range is present
has_a = (vmin < -linthresh)
Expand Down