First page Back Continue Last page Overview Graphics

Tick Label Rendering

The tick labels can be accessed via the get_text method of the class <class 'matplotlib.axes.AxesSubplot'>, i.e. the ax object of our example.

A value for a tick can be changed with the set_bbox method.

Getting all the tick labels:

labels = [xtick.get_text() for xtick in ax.get_xticklabels()]

If print(labels) is applied, we see the following output:

['$-2\\pi$', '$-\\pi$', '$+\\pi$', '$+2\\pi$']

We can adjust all the labels now by indexing labels:

Labels[1] = '42'

This resets sets the new tick labels:

ax.set_xticklabels(labels)