The function ball_height
computes the height of the ball at a given time:
def ball_height(t, v_0=10):
g = 9.81
return v_0*t - 0.5*g*t**2
We use this function to plot the height of the ball during the first second of its movement:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0,1)
plt.figure(figsize=(4,2))
plt.plot(t, ball_height(t))
plt.xlabel('time (sec)')
plt.ylabel('height (meters)')
plt.title('Ball height vs time', fontsize=10)
plt.show()