第一个是设置坐标轴的范围,第二个是设置精度及精度的范围:
程序:
import matplotlib.pyplot as plt import numpy as np ax = plt.gca() ax.set_xlim(-10,10) ax.set_ylim(-10,10) #网格 plt.grid(linestyle='-.') #linestyle = ls my_x1 = np.arange(-5,5,0.5) plt.xticks(my_x1) plt.show()
结果:
2024-03-19 15:11:34
第一个是设置坐标轴的范围,第二个是设置精度及精度的范围:
程序:
import matplotlib.pyplot as plt import numpy as np ax = plt.gca() ax.set_xlim(-10,10) ax.set_ylim(-10,10) #网格 plt.grid(linestyle='-.') #linestyle = ls my_x1 = np.arange(-5,5,0.5) plt.xticks(my_x1) plt.show()
结果:
下一篇:Python 箱线图