python matplotlib.pyplot中的 LinearLocator(n+1)可以将坐标轴分成n个相等区间
使用例如
ax=plt.axes((0.2,0.2,0.5,0.5))#添加坐标轴
loc=plt.LinearLocator(numticks=4)#将坐标轴三等分
ax.xaxis.set_major_locator(loc)
ax.yaxis.set_major_locator(loc)#分别对x,y轴调用该函数
plt.show()
运行截图为
python matplotlib.pyplot中的 LinearLocator(n+1)可以将坐标轴分成n个相等区间
使用例如
ax=plt.axes((0.2,0.2,0.5,0.5))#添加坐标轴
loc=plt.LinearLocator(numticks=4)#将坐标轴三等分
ax.xaxis.set_major_locator(loc)
ax.yaxis.set_major_locator(loc)#分别对x,y轴调用该函数
plt.show()
运行截图为