2013/3/14 Andrew H. Jaffe <a.h.jaffe@...287...>:
Dear all,
None of the obvious ways for changing ticklabels seem to work for the current version of Matplotlib (1.2.0 for me). At present, ax.yaxis.get_ticklabels().get_text() returns empty strings, as does ax.get_yticklabels(), and the equivalent set_* functions don't seem to have any effect.
It seems to be working for me. I'm using a development version but I
don't thing this has changed.
In [1]: import matplotlib.pyplot as plt
In [2]: plt.get_backend()
Out[2]: 'TkAgg'
In [3]: plt.plot([1, 2])
Out[3]: [<matplotlib.lines.Line2D at 0x424c310>]
In [4]: plt.draw()
In [5]: labels = plt.gca().get_yticklabels()
In [6]: map(lambda x: x.get_text(), labels)
Out[6]: [u'1.0', u'1.2', u'1.4', u'1.6', u'1.8', u'2.0', u'2.2', '']
In [7]: plt.gca().set_yticklabels(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])
Out[7]:
[<matplotlib.text.Text at 0x3e97bd0>,
<matplotlib.text.Text at 0x3ea2390>,
<matplotlib.text.Text at 0x42bed90>,
<matplotlib.text.Text at 0x42c0390>,
<matplotlib.text.Text at 0x42c05d0>,
<matplotlib.text.Text at 0x42c0c50>,
<matplotlib.text.Text at 0x42c1310>,
<matplotlib.text.Text at 0x42c1990>]
In [8]: map(lambda x: x.get_text(), labels)
Out[8]: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
Goyo