Erase/delete lines from a plot

I have a software that draws, sequentially, Bezier curves, in a graph, as the coordinates of the vertices are modified
I need that before drawing a new line, the last line drawn is erased, before drawing the next one.
Attached a part of the code.
curve=BPoly(vertices[:,np.newaxis,:],[0,1])
xx=np.linspace(0,1,100)
yy=curve(xx)
plt.plot(*yy.T, color=‘r’)
plt.show()
What will be the solution?

Did you have a look at Animated line plot — Matplotlib 3.6.3 documentation