import numpy as np
import matplotlib.pyplot as plt
def f(t):
return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
plt.figure(1)
plt.subplot(211)
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
plt.subplot(212)
plt.plot(t2, np.cos(2*np.pi*t2), 'r--')
plt.show()
According to offical Matplotlib document(https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.figure) A figure function will
"If num is provided, and a figure with this id already exists, make it active, and returns a reference to it. "
I tried do the above on my Ipython without plt.figure, but it showed the two required pictures still.