只是想知道在python的matplotlib中,如何使对数x轴刻度如附图所示(即,从1到4.5每隔0.5个间距有标签的主要刻度;每0.1个间距没有标签的次要刻度):
我尝试过一些方法,例如
ax1.set_xticks([1.5,2,2.5,3,3.5,4,4.5])
ax1.xaxis.set_major_formatter(FormatStrFormatter('%.1f'))
ax1.xaxis.set_minor_locator(LogLocator(base=1,subs=(0.1,)))
但它没有给我正确的解决方案。
使用
matplotlib.pyplot.semilogx
功能:
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.semilogx.html