Take a look at Formatter classes. If you do not put text on your ticks, you will almost never directly use set_xticklabels or set_yticklabels . This completely cancels your label labels from your data. If you adjust the presentation limits, the tick marks will remain the same.
In your case, there is a formatter for this:
fig, ax = plt.subplots() ax.loglog(np.logspace(0, 5), np.logspace(0, 5)**2) ax.xaxis.set_major_formatter(matplotlib.ticker.LogFormatterExponent())
matplotlib.ticker.LogFormatterExponent doc
In general, you can use FuncFormatter . For an example of using FuncFomatter see matplotlib: change yaxis tag labels , one of many examples floating around SO.
A brief example of what you want, lifting up exactly from JoeKington in the comments:
ax.xaxis.set_major_formatter( FuncFormatter(lambda x, pos: '{:0.1f}'.format(log10(x))))
tacaswell
source share