What is the correct way to replace matplotlib tick labels with computed values?

Viewed 4436

I have a figure with a log axis

enter image description here

and I would like to relabel the axis ticks with logs of the values, rather than the values themselves

enter image description here

The way I've accomplished this is with

plt.axes().set_xticklabels([math.log10(x) for x in plt.axes().get_xticks()])

but I wonder if there isn't a less convoluted way to do this.

What is the correct idiom for systematically relabeling ticks on matplotlib plots with values computed from the original tick values?

1 Answers
Related