Skip to content

[ENH]: Improve tick density near zero for SymmetricalLogLocator #31386

@saitejaponnam12

Description

@saitejaponnam12

Problem

When using SymmetricalLogLocator (symlog scale), the linear region around zero often has very sparse tick density.
This is especially noticeable when linthresh is small compared to the data range. As a result, plots become harder to read near zero because there are not enough ticks to understand scale transitions.

Currently, the linear region typically contains only a minimal number of ticks, which can make the visualization uneven compared to logarithmic regions.

Proposed solution

Proposed approach

One possible approach is to add a small number of evenly spaced ticks within the linear region [-linthresh, linthresh] when both logarithmic and linear segments are present.

This could:

  • Respect the existing numticks budget
  • Add only a limited number of linear ticks
  • Preserve ordering and uniqueness
  • Avoid affecting minor tick locators

The goal is to improve readability near zero while maintaining current logarithmic behavior elsewhere.

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()

Before

Image

After

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions