import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2 * np.pi, 100)
plt.plot(x, np.sin(x))
plt.show()
plt.plot(x, np.cos(x))
plt.show()
This example produces two consecutive plots in two windows, first the one on the left, then the one on the right:
As you can see, the sine disappeared and only the cosine shows up in the second window; the plot window has been cleared in between. However, this is what I want:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2 * np.pi, 100)
plt.plot(x, np.sin(x))
plt.show()
plt.plot(x, np.sin(x))
plt.plot(x, np.cos(x))
plt.show()
How can I keep the previous plot so it shows up in the second plot, too? There has to be a better way other than simply repeating the previous call to plt.plot?

