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

Skip to content

ax.get_xaxis().get_minorticklabels() always returns list of empty strings #13968

Closed
@tdegeus

Description

@tdegeus

Bug report

Bug summary

ax.get_xaxis().get_minorticklabels() always returns list of empty strings.

Code for reproduction

import matplotlib
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ax.set_xscale('log')
ax.set_yscale('log')

ax.set_xlim([2e-2, 2e-1])
ax.set_ylim([2e+1, 2e+3])

ax.plot([0.02, 0.1, 0.2], [20, 1000, 2000])

ax.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
ax.get_xaxis().set_minor_formatter(matplotlib.ticker.ScalarFormatter())

fig.canvas.draw()

print([item.get_text() for item in ax.get_xaxis().get_minorticklabels()])

plt.show()

Actual outcome

['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']

test

Expected outcome

['0.00', '0.00', '0.00', '0.01', '0.01', '0.01', '0.01', '0.01', '0.02', '0.03', '0.04', '0.05', '0.06', '0.07', '0.08', '0.09', '0.20', '0.30', '0.40', '0.50', '0.60', '0.70', '0.80', '0.90', '2.00', '3.00', '4.00', '5.00', '6.00', '7.00', '8.00', '9.00', '20.00', '30.00', '40.00', '50.00', '60.00', '70.00', '80.00', '90.00']

Matplotlib version

  • Operating system: macOS Mojave 10.14.4
  • Matplotlib version: 3.0.3
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: 3.7.3

Python installed using homebrew, matplotlib using pip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions