Home>

### only the frame of the figure is displayed in python,

http://dsng.hatenablog.com/entry/2013/02/06/150713
Trying to animate the Lotka Volterra equation, see https://omedstu.jimdo.com/2018/06/21/fitzhugh-nagumo model in animation/
I tried remodeling the code written on the above site,
Only the frame of the figure appears and no animation is displayed

Because I am a beginner in programming and scientific calculation, I have no idea where to fix it.
Thank you.

Error message
``````Animation is not displayed
Only the frame of the figure comes out
Copy and paste is where do not know what went wrong because it is written in the center``````
Applicable source code
``````% matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import scipy.integrate as integrate
from matplotlib.animation import FuncAnimation

a = 2. # Prey birth rate
b = .1 # prey prey rate
c = 1.5 # predator mortality
d = 0.75 # Predator increase rate
def lotka_volterra (state, t):
prey, pred = state
dot_prey = prey * (a-b * pred)
dot_pred = pred * (-c + d * b * prey)
return dot_prey, dot_pred
prey0 = 10
prey0 = 5
fig = plt.figure ()
t = np.arange (0.0, 10, 0.01)
len_t = len (t)
dt = 5
def update (i):
global y, y0
if i == 0:
y0 = [prey0, pred0]
plt.cla ()
y = integrate.odeint (lotka_volterra, y0, t)
y0 = (y [dt, 0], y [dt, 1])
prey = y [:, 0]
pred = y [:, 1]
plt.plot (t, prey, label = "prey: prey", color = "# ff7f0e")
plt.plot (t, pred, label = "pred: predator", color = "# 1f77b4")
plt.plot (t [len_t-1], prey [len_t-1], 'o--', color = "# ff7f0e")
plt.plot (t [len_t-1], pred [len_t-1], 'o--', color = "# 1f77b4")
plt.grid ()
plt.legend (bbox_to_anchor = (0, 1),
loc = 'upper left',