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

[Bug]: LogFormatter minor ticks withminor_thresholds of (0,0) does not behave as documented #25896

Open
@ksunden

Description

@ksunden

Bug summary

In investigating#25894 I discovered that despite being documented as:

To disable labeling of minor ticks when 'labelOnlyBase' is False, useminor_thresholds=(0, 0). This is the default for the "classic" style.

It actually only removes some minor tick labels (e.g. with base of 10: 11-14 will get labels, but 16-19 (15 is edge case, dependent on floating point rounding, 1.4, or 140 also similar))

Code for reproduction

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)plt.show()

Actual outcome

Figure_2

formatter(10)# '10'formatter(11)# '11'formatter(12)# '12'formatter(13)# '13'formatter(14)# '14'formatter(15)# '15'formatter(16)# ''

Expected outcome

Figure_2

formatter(10)# ''formatter(11)# ''formatter(12)# ''formatter(13)# ''formatter(14)# ''formatter(15)# ''formatter(16)# ''

Additional information

Only really affects plots that are zoomed in to much less than one decade, which arguably doesn't make sense to use a log scale, but still seems incongruous with the documented "this turns off minor ticks".

Has to do with whencoeff rounds down to1 in:

fx=math.log(x)/math.log(b)
is_x_decade=_is_close_to_int(fx)
exponent=round(fx)ifis_x_decadeelsenp.floor(fx)
coeff=round(b** (fx-exponent))
ifself.labelOnlyBaseandnotis_x_decade:
return''
ifself._sublabelsisnotNoneandcoeffnotinself._sublabels:
return''

I'm notquite sure what the proper solution is, perhaps makingself._sublabels=set() instead?

Operating system

Linux

Matplotlib Version

3.8 (main)

Matplotlib Backend

No response

Python version

3.11

Jupyter version

No response

Installation

git checkout

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp