Deleting lines from a plot

If you know which line you want to delete, you can call
ax.lines.remove(line) where line is a line instance.

    In [1]: line1, = plot(rand(10), 'ro')
    In [2]: line2, = plot(rand(20), 'b--s')
    In [3]: ax = gca()
    In [4]: ax.lines.remove(line1)
    In [5]: draw()

If you haven't saved the line instance, but can otherwise identify it
(eg you know it was the first line you plotted), you can do something


or if you have labeled the line, you can identify and remove it with

  plot(x,y,label='my line')
  line = [line for line in ax.lines if line.get_label()=='my line'][0]