Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: LogFormatter minor ticks with minor_thresholds of (0,0) misbehaves#26277

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Rylie-W wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromRylie-W:bugfix-for-issue-25896

Conversation

Rylie-W
Copy link

PR summary

PR checklist

@oscargus
Copy link
Member

(Deleted my comment since I realized that it can be both an empty set and None.)

Seems like this breaks several other things.

Rylie-W reacted with thumbs up emoji

@Rylie-WRylie-W marked this pull request as draftJuly 9, 2023 20:52
@Rylie-WRylie-Wforce-pushed thebugfix-for-issue-25896 branch from3f120f7 to13b8af4CompareJuly 10, 2023 06:37
@Rylie-WRylie-Wforce-pushed thebugfix-for-issue-25896 branch from13b8af4 toe06b857CompareJuly 10, 2023 17:39
@Rylie-W
Copy link
Author

I'm not sure which fix is better, or if there is any other superior solution available. Based on the commit history, there are two potential fixes:

  1. alternative fix. The fix produces theexpected outcomeand aligns with the description in thedoc:

If labelOnlyBase is False, these two numbers control the labeling of ticks that are not at integer powers of base; normally these are the minor ticks. The controlling parameter is the log of the axis data range. In the typical case where base is 10 it is the number of decades spanned by the axis, so we can call it 'numdec'. If numdec <= all, all minor ticks will be labeled. If all < numdec <= subset, then only a subset of minor ticks will be labeled, so as to avoid crowding. If numdec > subset then no minor ticks will be labeled.
...
To disable labeling of minor ticks when 'labelOnlyBase' is False, use minor_thresholds=(0, 0). This is the default for the "classic" style.

Note that it assumeslabelOnlyBase isTrue for all the major formatters whileFalse for minor formatters, which could contradict with thedoc stating:

This is normally True for major ticks and False for minor ticks.

What about "abnormally"? Can a major formatter have 'labelOnlyBase' set toFalse? Is there an exceptional case?

  1. FIX: LogFormatter minor ticks with minor_thresholds of (0,0) misbehaves. It uses the same minor_thresholds logic for both major and minor formatter, and allows a major formatter withlabelOnlyBase=False or a minor formatter withlabelOnlyBase=True. But it contradicts with the following description in the documentation:

If labelOnlyBase is False, these two numbers control the labeling of ticks that are not at integer powers of base; normally these are the minor ticks. The controlling parameter is the log of the axis data range. In the typical case where base is 10 it is the number of decades spanned by the axis, so we can call it 'numdec'. If numdec <= all, all minor ticks will be labeled. If all < numdec <= subset, then only a subset of minor ticks will be labeled, so as to avoid crowding. If numdec > subset then no minor ticks will be labeled.

Whenminor_thresholds is set to(0, 0), namely,numdec > subset, a formatter labels bases only whetherlabelOnlyBase is True or not. In the example from issue#25896, its outcome is as follows:

importmatplotlib.pyplotaspltimportmatplotlib.tickerasmtickerfig,ax=plt.subplots()ax.set_yscale("log")formatter=mticker.LogFormatter(minor_thresholds=(0,0))ax.yaxis.set_minor_formatter(formatter)ax.set_ylim(10,20)formatter(10)# '10'formatter(11)# ''formatter(12)# ''formatter(13)# ''formatter(14)# ''formatter(15)# ''formatter(16)# ''

Furthermore, what does the term "classic" style refer to in the documentation? Maybe we could provide a more precise description.

@Rylie-WRylie-W marked this pull request as ready for reviewJuly 11, 2023 17:05
@oscargus
Copy link
Member

Classic is the pre-2.0 default style.

Rylie-W reacted with thumbs up emoji

fix test failuresalternative fixfix formatremove irrelevant coderemove label_expected
@Rylie-WRylie-Wforce-pushed thebugfix-for-issue-25896 branch from29b913a to6e9179dCompareJuly 22, 2023 12:11
@Rylie-W
Copy link
Author

Hi@oscargus, could you review the PR again?

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

@oscargusoscargusoscargus left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Bug]: LogFormatter minor ticks withminor_thresholds of (0,0) does not behave as documented
3 participants
@Rylie-W@oscargus@melissawm

[8]ページ先頭

©2009-2025 Movatter.jp