Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Setting xticklabels causes warning related to FixedFormatter #18848

Closed
@igurin-invn

Description

@igurin-invn

Bug report

Bug summary

I get a warning related to FixedFormatter even though I am not setting a formatter.

Thanks to user Rational-IM on StackOverflow and the good folks at pandas for isolating and reproducing the bug.

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.scatter(0.5, 0.5)
ax.set_xticklabels(['0', r'$T/2$', r'$T$'])

# Optional line
ax.xaxis.set_major_locator(FixedLocator([0, 0.5, 1]))

None

Actual outcome

<ipython-input-3-52a3699e4278>:5: UserWarning: FixedFormatter should only be used together with FixedLocator
  ax.set_xticklabels(['0', r'$T/2$', r'$T$'])

Expected outcome

Works on 3.2.2 with no warning.

Matplotlib version

  • Operating system: Win 10
  • Matplotlib version: 3.3.2
  • Matplotlib backend: module://ipykernel.pylab.backend_inline
  • Python version: 3.8.5
  • Jupyter version (if applicable): 6.1.4
  • Other libraries: none

Installed from conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions