Skip to content

[Bug]: LogLocator sometimes draws fewer ticks than it can #29694

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
anntzer opened this issue Feb 28, 2025 · 1 comment · Fixed by #29698
Closed

[Bug]: LogLocator sometimes draws fewer ticks than it can #29694

anntzer opened this issue Feb 28, 2025 · 1 comment · Fixed by #29698

Comments

@anntzer
Copy link
Contributor

anntzer commented Feb 28, 2025

Bug summary

Sometimes, LogLocator draws fewer ticks than it can due to less than optimal log stride selection.

Code for reproduction

from pylab import *

# At this figure size there's room for two y ticks
# (check with ax.yaxis.get_tick_space())
# which could be placed e.g. at 10^0 and 10^4,
# but only one tick is drawn at 10^2.
figure(figsize=(5, 1)).add_subplot(yscale="log", ylim=(.5, 15000))

Actual outcome

See comment above.

Expected outcome

See comment above.

Additional information

I suspect that the formulas for stride and decades in LogLocator.tick_values() are faulty.

Operating system

any

Matplotlib Version

3.11.0.dev511+g0b7a88a967

Matplotlib Backend

any

Python version

3.13

Jupyter version

no

Installation

git checkout

@timhoffm
Copy link
Member

timhoffm commented Mar 1, 2025

From a quick check: in tick_values() your example has numticks=2 but only one is eventually rendered. When changing to figsize=(5, 1.1), numticks=3 but two are rendered. So yes, there's some logic error in the calculation.

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

Successfully merging a pull request may close this issue.

3 participants