I'm trying to replace plt.hold() which accumulates lines in a figure.
Research: Several posted suggestions to this issue say to use multiple
plt.plot(x,y) commands followed by plt.show(). On my system (Python 3.6) that
prints only the content of the last plt.plot() call.
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0, 2*np.pi, 400)
a = np.sin(t)
b = np.cos(t)
plt.plot(t, a, 'b')
plt.show()
Adding another plt.plot() call clears the first line
plt.plot(t, a, 'b')
plt.plot(t, b, 'g')
plt.show()
A method that works is to put them all in one plt.plot() call.
plt.plot(t, a, 'r--', t, b, 'b')
plt.show()
But I have five lines with labels to plot so this would be a long, hard-to-read argument list.
How can I define each of the lines individually for one figure?


