1import matplotlib.pyplot as plt
2
3fig, ax = plt.subplots()
4
5# We need to draw the canvas, otherwise the labels won't be positioned and
6# won't have values yet.
7fig.canvas.draw()
8
9labels = [item.get_text() for item in ax.get_xticklabels()]
10labels[1] = 'Testing'
11
12ax.set_xticklabels(labels)
13
14plt.show()
15