如何在matplotlib的轴刻度中删除小数点后的数字?

max*_*x29 6 python matplotlib

我有

tick_location = np.linspace(0.01, 10, num=10, endpoint=True)
ax2.set_xticks(tick_location)
tick_labels = np.around(1/new_tick_loc*1e4,decimals=-2)
ax2.set_xticklabels(tick_labels)
Run Code Online (Sandbox Code Playgroud)

这个(以及一些额外的代码)产生了下面的图,但是我想从顶部x轴上的刻度标签中删除小数点和后面的数字.

使用matplotlib.ticker.FormatStrFormatter(fmt)没有帮助

顶部x轴带小数

Mik*_*ler 7

将数字转换为整数:

ax2.set_xticklabels(tick_labels.astype(int))
Run Code Online (Sandbox Code Playgroud)