Skip to content

Improve tick density near zero for SymmetricalLogLocator#31381

Closed
saitejaponnam12 wants to merge 3 commits intomatplotlib:mainfrom
saitejaponnam12:improve-symlog-tick-density
Closed

Improve tick density near zero for SymmetricalLogLocator#31381
saitejaponnam12 wants to merge 3 commits intomatplotlib:mainfrom
saitejaponnam12:improve-symlog-tick-density

Conversation

@saitejaponnam12
Copy link

PR summary

Improve tick density near zero for SymmetricalLogLocator.

When using the symlog scale, the linear region around zero often produces too few ticks, making plots harder to interpret.
This change adds a small number of evenly spaced ticks in the linear region and merges them with the logarithmic ticks while preserving ordering and uniqueness.

Example:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-100, 100, 1000)
y = x

fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_yscale('symlog')
plt.show()

This improves readability near zero without affecting logarithmic regions.

AI Disclosure

AI assistance was used to explore approaches and refine structure. The final implementation and testing were manually verified.

PR checklist

  • "closes #0000" is in the body of the PR description
  • new and changed code is tested
  • Plotting related features are demonstrated in an example
  • [N/A] New Features and API Changes are noted
  • [N/A] Documentation complies with guidelines

Copilot AI review requested due to automatic review settings March 25, 2026 16:40

This comment was marked as spam.

…ator

- Handle None value for numticks parameter explicitly
- Reject invalid values (numticks <= 0)
- Strictly respect numticks budget: min(5, numticks) only when positive
- Constrain linspace bounds to linear region: max(vmin, -linthresh) to min(vmax, linthresh)
- Add safety guard: only create linear ticks if linear_vmax > linear_vmin
- Prevents exceeding set tick count in all edge cases

Addresses code review feedback about budget respect.
- Split long lines to <= 88 characters
- Split comment across lines
- Use hanging indents for long function calls
- Remove trailing whitespace
- Follow Matplotlib code style conventions
@scottshambaugh
Copy link
Contributor

scottshambaugh commented Mar 25, 2026

Please share some before/after screenshots demonstrating the issue and your change. I think generally we would want a change like this to be opened as an issue first, so that we can discuss if it's needed or not

@scottshambaugh
Copy link
Contributor

scottshambaugh commented Mar 25, 2026

Closing this because you have not yet completed your first PR. Please see that through to completion before opening a second: #31361 (comment)

For the ticks change you are describing here, please open it as an issue for discussion instead, with more details of why the change is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants