Skip to content

default tick formatter could switch to scientific notation earlier #14800

@anntzer

Description

@anntzer

Bug report

Bug summary

The default tick formatter switches to scientific notation only for very small values, but there is a range of slightly bigger values where scientific notation would be better too.

Code for reproduction

import matplotlib.pyplot as plt
plt.rcdefaults()
axs = plt.figure().subplots(2)
axs[0].set(xlim=(1e-7, 21e-7))
axs[1].set(xlim=(1e-8, 21e-8))
plt.show()

Actual outcome

test

Expected outcome

Either the top axes should also use scientific notation (note that this also happens e.g. 1e-6 and 1e-5), or we need something smarter to determine the number of ticks.
IIRC the default ticker places ticks assuming that labels will have a width of no more than ~3 character heights(?), so allowing for 4-5 digits before switching to scientific notation may make sense.

Matplotlib version

  • Operating system: linux
  • Matplotlib version: head, at least as far back as 3.0
  • Matplotlib backend (print(matplotlib.get_backend())): qt5agg
  • Python version: 37
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions