Skip to content

Label log minor ticks if only one log major tick is drawn.#29054

Merged
QuLogic merged 1 commit into
matplotlib:mainfrom
anntzer:lmt
Dec 19, 2024
Merged

Label log minor ticks if only one log major tick is drawn.#29054
QuLogic merged 1 commit into
matplotlib:mainfrom
anntzer:lmt

Conversation

@anntzer

@anntzer anntzer commented Oct 31, 2024

Copy link
Copy Markdown
Contributor

In general, avoiding axis with a single labeled tick seems to be a good idea. Previously, a log axis spanning from 4 to 60 would have its minor ticks unlabeled, LogFormatter making that choice based on the fact that the axis spans more than one decade (60/4>10). Instead, change the interpretation of the first item in minor_thresholds to label the minor ticks (by default) if there is only one (or zero) major tick drawn (as is the case for the above axis limits).

Closes #29050, but probably needs to be discussed as that's technically an API break. However, note that this doesn't break any test and I suspect that this case may have been missed previously (I added a test for it).

PR summary

PR checklist

@anntzer anntzer added API: changes Changes to the public API, typically requiring deprecation. topic: ticks axis labels labels Oct 31, 2024
@anntzer

anntzer commented Dec 15, 2024

Copy link
Copy Markdown
Contributor Author

Bumping, at least for discussion?

Comment thread lib/matplotlib/ticker.py Outdated
@oscargus

Copy link
Copy Markdown
Member

I think it makes sense for the default behavior! I do not fully understand the consequences if someone provides a value, though, and therefore how "much breaking" this is.

@greglucas greglucas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me and seems like a sensible change to the default.

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO the change is ok, even though it's technically breaking. I doubt somebody is explicitly relying (or wanting) the preivious behavior.

Comment thread doc/api/next_api_changes/behavior/29054-AL.rst Outdated
In general, avoiding axis with a single labeled tick seems to be a good
idea.  Previously, a log axis spanning from 4 to 60 would have its minor
ticks unlabeled, LogFormatter making that choice based on the fact that
the axis spans more than one decade (60/4>10).  Instead, change the
interpretation of the first item in `minor_thresholds` to label the
minor ticks (by default) if there is only one (or zero) major tick drawn
(as is the case for the above axis limits).
@timhoffm timhoffm added this to the v3.11.0 milestone Dec 17, 2024
@QuLogic QuLogic merged commit 9db1b97 into matplotlib:main Dec 19, 2024
@anntzer anntzer deleted the lmt branch December 19, 2024 06:23
@timhoffm timhoffm mentioned this pull request Apr 3, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API: changes Changes to the public API, typically requiring deprecation. topic: ticks axis labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: LogFormatter(minor_thresholds=...) should count actually drawn ticks, not number of decades spanned by axes

5 participants