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

MaxNLocator changes the scientific notation exponent with different number of tick labels #12072

Closed
Milestone
@joelostblom

Description

@joelostblom

Bug report

Bug summary

MaxNLocator changes the scientific notation with different number of tick labels.

Code for reproduction

I encountered this unexpected behavior when I changed the y-ticklabel size. Going from size 13 to 14 changes the scientific notation from 1e9 to 1e10, and adds an decimal offset to all the ticklabels.

importmatplotlib.pyplotaspltsci_nums= [10**9,8*10**9]plt.rcParams['ytick.labelsize']=13fig,ax=plt.subplots()ax.scatter(range(len(sci_nums)),sci_nums)

image

plt.rcParams['ytick.labelsize']=14fig,ax=plt.subplots()ax.scatter(range(len(sci_nums)),sci_nums)

image

This is related to that the larger font size reduces the number of tickslabels.MaxNLocator apparently adjusts the scientific notation depending on the number of ticklabels.

plt.rcParams['ytick.labelsize']=13fig,ax=plt.subplots()ax.scatter(range(len(sci_nums)),sci_nums)importmatplotlib.tickerastickerax.yaxis.set_major_locator(ticker.MaxNLocator(4))

image

I dont' quite understand the rule thatMaxNLocator uses. Setting 1, 2, 4 or 5 ticklabels results in1e10. Setting 3, 6, 7, 8, or 9 ticklabels results in1e9.

Expected outcome
I would expect that changing the number of ticklabels (either directly or via another parameter such as the font size) would not result in a change in the formatting of the scientific notation. In this case, I would expect it to remain1e9 for all the examples above.

Matplotlib version

  • Operating system:Linux
  • Matplotlib version:2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())):module://ipykernel.pylab.backend_inline
  • Python version:3.6.6 (conda-forge)
  • Jupyter version (if applicable):jupyterlab=0.34.3, jupyter_core=4.4.0
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp