Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erase ellipse from figure?

I'm new at python and new at graphics!! the thing is that I'm implementing an EKF map-based localization and I want to plot the uncertenty ellipse. For that I do, each time I want to update the figure with all the values I call a function call animate, which inside has this:

ellipse = matplotlib.patches.Arc([x_B_1[0,0],x_B_1[0,1]],P_B_1[0,0],P_B_1[1,1],x_B_1[0,2]*180/pi,color='green', linewidth='0.5')
ax.add_patch(ellipse)

And some other stuff

The thing is that by doing this all the ellipses saty in the figure and I get a mess (I can not post a picture of the figure because it's my first post and the forum does not allow me to do it), I want just the last ellipse.

How can I do it?


I can not do that because everything in the figure is lost, I just want to erase the ellipse not the rest of the things that I have on that figure, maybe it's not possible... Is there any option of updating the ellipse parameters so instead of drawing a new one I just update the one already drawn??

Cheers!

like image 543
user1340669 Avatar asked Apr 18 '12 07:04

user1340669


2 Answers

ellipse.remove() should do what you want

like image 113
kevmitch Avatar answered Sep 22 '22 14:09

kevmitch


I think your problem is that you have to clear the figure before you plot something else. Try with the clf() command of matplotlib

like image 33
maupertius Avatar answered Sep 20 '22 14:09

maupertius