Skip to content

[WIP] Avoid a log-formatted tick in the linear region of SymLog #14309

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

Closed
wants to merge 3 commits into from
Closed
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
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/symlog.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/symlog2.pdf
Binary file not shown.
37 changes: 14 additions & 23 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2408,33 +2408,24 @@ def tick_values(self, vmin, vmax):
#
# "simple" mode is when the range falls entirely within (-t,
# t) -- it should just display (vmin, 0, vmax)
if -linthresh < vmin < vmax < linthresh:
return [vmin, vmax]

# Determine which of the three ranges we have
has_a = has_b = has_c = False
if vmin < -linthresh:
has_a = True
if vmax > -linthresh:
has_b = True
if vmax > linthresh:
has_c = True
elif vmin < 0:
if vmax > 0:
has_b = True
if vmax > linthresh:
has_c = True
else:
return [vmin, vmax]
elif vmin < linthresh:
if vmax > linthresh:
has_b = True
has_c = True
else:
return [vmin, vmax]
has_a = (vmin < -linthresh)
has_c = (vmax > linthresh)

if (has_a and vmax > -linthresh) or (has_c and vmin < linthresh):
has_b = True
else:
has_c = True
has_b = False

def get_log_range(lo, hi):
lo = np.floor(np.log(lo) / np.log(base))
"""
Get the first integer exponents above *lo* and *hi*. These are
chosen to be above in both cases to avoid encroaching range b for
lo, and to extend out of ranges a or c for hi.
"""
lo = np.ceil(np.log(lo) / np.log(base))
hi = np.ceil(np.log(hi) / np.log(base))
return lo, hi

Expand Down