坐标轴范围
函数参数
- plt.axis()
plt.axis([横轴起始,横轴终止,纵轴起始,纵轴终止])
- plt.xlim()
调两边 xlim([起始,终止]) xlim(xmin= ,xmax=)
调一边 xlim(xmin=) xlim(xmax=)
- plt.ylim()
代码
import matplotlib.pyplot as plt
import numpy as np
x=np.arange(-10,11,1)
plt.plot(x,x*x)
plt.axis()
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x=np.arange(-10,11,1)
plt.plot(x,x*x)
plt.axis([-5,5,20,100])
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x=np.arange(-10,11,1)
plt.plot(x,x*x)
plt.xlim([-5,5])
plt.ylim([0,60])
plt.show()
import matplotlib.pyplot as plt