Closed
Description
In the following example I am getting back the wrong labels from ax.xaxis.get_ticklabels
:
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter, MaxNLocator
ax = plt.subplot(1,1,1)
def formatter_func(pos, *args):
return 'a' if pos == 1 else ''
ax.figure.canvas.draw()
print([tick.get_text() for tick in ax.xaxis.get_ticklabels()])
ax.xaxis.set_major_formatter(FuncFormatter(formatter_func))
ax.xaxis.set_major_locator(MaxNLocator(10, integer=True))
ax.set_xlim(-0.5, 2.5)
ax.figure.canvas.draw()
print([tick.get_text() for tick in ax.xaxis.get_ticklabels()])
This gives:
['0.0', '0.2', '0.4', '0.6', '0.8', '1.0']
['0.0', '', 'a', '', '0.8']
whereas I expected:
['0.0', '0.2', '0.4', '0.6', '0.8', '1.0']
['', '', 'a', '', '']
Metadata
Metadata
Assignees
Labels
No labels