I want to remove a specific line in a plot of multiple lines. Bellow is a given example which is not sufficient for me because it removes only the last plotted line and not
You can also use this for multiple subplots
subfig, subax = plt.subplots(3)
def add_series(x, y0, y1, y2, gid):
plt.figure(subfig.number)
ln, = subax[0].plot(x, y0, gid=gid)
ln, = subax[1].plot(x, y1, gid=gid)
ln, = subax[2].plot(x, y2, gid=gid)
plt.draw()
def remove_series(self, gid):
plt.figure(subfig.number)
for c0, c1, c2 in zip(subax[0].lines, subax[1].lines, subax[2].lines):
if c0.get_gid() == gid:
c0.remove()
if c1.get_gid() == gid:
c1.remove()
if c2.get_gid() == gid:
c2.remove()
plt.draw()