我正在尝试使用不同的名称循环保存图像。我的代码正在执行,没有错误,但是文件没有保存。它虽然显示警告。
y1 = linspace(0.51,0.61,0.01,endpoint=True)
y2 = linspace(0.52,0.62,0.01,endpoint=True)
name = linspace(1,11,1,endpoint=True)
for i,j,k in zip(y1,y2,name):
fig,ax = plt.subplots()
A = (a**2)*sin(p)*sqrt(1-sin(p)*sin(p))
B = (a*b*d)/(sin(p)**2)
C = a*b*d
D = a*c*sqrt(1-sin(p)*sin(p))
E = a*c*sin(p)*sqrt(1-sin(p)*sin(p))
F = (b*c*d)/(sin(p)**3)
G = (b*c*d)/sin(p)
H = a*d* ( (a/(sin(p)*sin(p))) - a + (c/(sin(p)**3)) - (c/(sin(p))) )
t = abs((A+B-C+D+E+F-G) / (H))
ax.scatter(angle_degrees,t)
ax.xlim(0,-90)
ax.ylim(i,j)
ax.set_xlabel('Angle', fontsize=16)
ax.set_ylabel('Time', fontsize=16)
ax.set_title('Formula 1', fontsize=16)
plt.savefig('A{}.png'.format(k))
我不明白问题是什么。虽然有警告
DeprecationWarning: object of type <class 'float'> cannot be
safely interpreted as an integer.
app.launch_new_instance()
答案 0 :(得分:0)
这次我明白了。 linspace 中的参数是错误的。我将其视为 arange 。我的错。这是正确的代码:
y1 = linspace(0.51,0.61,10,endpoint=True)
y2 = linspace(0.52,0.62,10,endpoint=True)
name = linspace(1,11,10,endpoint=True)
for i,j,k in zip(y1,y2,name):
fig,ax = plt.subplots()
A = (a**2)*sin(p)*sqrt(1-sin(p)*sin(p))
B = (a*b*d)/(sin(p)**2)
C = a*b*d
D = a*c*sqrt(1-sin(p)*sin(p))
E = a*c*sin(p)*sqrt(1-sin(p)*sin(p))
F = (b*c*d)/(sin(p)**3)
G = (b*c*d)/sin(p)
H = a*d* ( (a/(sin(p)*sin(p))) - a + (c/(sin(p)**3)) - (c/(sin(p))) )
t = abs((A+B-C+D+E+F-G) / (H))
ax.scatter(angle_degrees,t)
ax.xlim(0,-90)
ax.ylim(i,j)
ax.set_xlabel('Angle', fontsize=16)
ax.set_ylabel('Time', fontsize=16)
ax.set_title('Formula 1', fontsize=16)
plt.savefig('A{}.png'.format(k))
感谢您的评论,伙计们。