import matplotlib.pyplot as plt
def my_plot(xx, vv, tt):
plt.plot(tt, xx, color = 'b', linestyle='--',label="height")
plt.plot(tt, vv, color = 'r', label="velocity")
plt.legend()
plt.xlabel('time')
plt.ylabel('height and velocity')
plt.grid()
plt.show()
def euler(x0, v0):
v1 = v0 - g * dt
x1 = x0 + v0 * dt
return x1, v1
#g, dt =9.8, 0.1
g, dt =9.8, 0.01
tt,xx,vv=[0.0],[0.0],[9.8] #for compare rain_drop
#tt,xx,vv=[0.0],[0.0],[9.8]
#tt,xx,vv=[10.0],[0.0],[0.0]
t = 0.0
for i in range(0,250): #250 for compare rain_drop
t += dt
x, v = euler(xx[-1],vv[-1])
tt.append(t)
xx.append(x)
vv.append(v)
# print(xx)
# print(vv)
my_plot(xx, vv, tt)