python - 从 plt.plot 中删除最后一个 while 循环
问题描述
我正在研究一些关于排放锥形罐的欧拉方程,但是在绘制模拟图时遇到了问题。
我的目的是在时间增加的同时减小坦克的半径。我想在第一个循环后删除第一条蓝线,但我不知道如何:(
这是代码:
import matplotlib.pyplot as plt
import numpy as np
Hi=0.5
hf=0
r=0.003
ang=8*np.pi/180
teta=np.tan(ang)**2
dt=1
g=9.8
t=0
t1=0
h=Hi
h2=0
R=np.tan(ang)*h
R1=np.tan(ang)*
Vh=[h]
Vt=[t]
Rt=[R]
f1 = plt.figure(1)
plot1=plt.plot([R-r,0,2*R,R+r,R-r],[0,Hi,Hi,0,0],"k")
plot1=line=plt.plot([0,2*R],[h,h],"b")
plt.grid()
plt.ylabel("ALtura del agua")
while h>0 and R>0:
h=((5*((2*g)**(1/2))*r**2)/(-2*teta*((Hi**(3/2)))))*dt+h
R=(np.tan(ang)*h)
t=t+dt
plot1=line=plt.plot([R1-R,R1+R],[h,h],"b")
Vh.append(h)
Vt.append(t)
Rt.append(R)
line[0].set_ydata([h])
plt.pause(1/24)
plt.title("Tiempo = "+str(t))
解决方案
试试这个删除最后一行:
if h <= 0:
h = 0
Vh.append(h)
Vt.append(t)
Rt.append(R)
line[0].set_ydata([h])
plt.pause(1/24)
plt.title("Tiempo = " + str(t))
告诉我它是否有用。问候
推荐阅读
- css - 当我更改 max-height 和 overflow-y 时,带有搜索输入/图标放置(绝对位置)的 Boostrap 4 导航栏不起作用
- excel - 为什么 findnext 方法在我的 excel VBA 代码中不起作用?
- python - Keras + mnist + 测试自己的图像。糟糕的预测
- javascript - 什么是 vb 中的 Javascript .map 等价物?
- java - Google 操作不会发送 actions.intent.MEDIA_STATUS
- python - 将 .tfrecords 文件拆分为多个 .tfrecords 文件
- typescript - 有什么方法可以在 tsconfig 中使用具有严格模式的 Loopback 4?
- java - 使用 Apache camel 在 Web 服务上重置连接
- java - DB2 - Java 驱动程序
- javascript - 使用 Javascript 运行 Observable