【发布时间】:2016-07-12 02:12:34
【问题描述】:
我正在尝试绘制图形 y= 5*x - 300/x,但我的输出只是一条直线,我不明白为什么。任何人都可以帮忙吗?谢谢
xvls= []
Rvls= []
for x in range(-100,100,1):
if x != 0:
def R(x):
f1 = 5*x
f2 = 300/x
f3 = f1+f2
return f3
error = 10
while error >= 1e-6:
error = R(x)-x
x = x -error
Rvls.append(R(x))
xvls.append(x)
else:
print 0
fig = plt.figure(figsize=(10,5))
xvls=np.linspace(-300,300, 25)
Rvls= np.linspace(-300,300, 25)
plt.subplot(1,2, 1)
plt.plot(xvls, Rvls, linestyle='-', marker='o', color='blue')
plt.xlabel('Distance from right hand pin')
plt.ylabel('Reaction force at left hand pin')
plt.title('The relationship between R(x) and x')
plt.rc('font', size=12)
plt.grid()
【问题讨论】: