先定义好主次轴刻度,然后再一起设置位置,类似这样:ax = plt.axes()ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi/2))ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi/4))详细做法参考这里:https://zhuanlan.zhihu.com/p/35052400
如有帮助请点采纳~
21行应该是set_minor_locator吧