[英]Why is the y axis in increments of 1 rather than 90
I want to make a sine graph but the y-axis is off, how can i change that.我想制作一个正弦图,但 y 轴关闭,我该如何改变它。
Also that do the 3 numbers in the brackets after linspace mean?另外,linspace 后面括号中的 3 个数字是什么意思?
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 7, 100)
y = np.sin(x)
plt.plot(x, y)
plt.grid(True)
plt.show()
Thank You谢谢你
See set_xlim to adjust the limits of the x-axis.请参阅set_xlim以调整 x 轴的限制。
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 7, 100)
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x,y)
ax.grid(True)
ax.set_xlim(0,7)
plt.show()
Before:前:
After:后:
The three numbers in the np.linspace command mean start , stop , and num . np.linspace 命令中的三个数字表示start 、 stop和num 。 Ie it generates an array of 100 evenly spaced numbers between 0 and 7.
即它生成一个由 0 到 7 之间的 100 个均匀间隔的数字组成的数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.