5

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!

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825

3 Answers3

4

ellipse.remove() should do what you want

kevmitch
  • 1,385
  • 1
  • 9
  • 10
1

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

maupertius
  • 1,518
  • 4
  • 17
  • 30
0

I see. You than want to, as you said, update the figure plot using set_data. Have a look at here for how to use it.

Community
  • 1
  • 1
maupertius
  • 1,518
  • 4
  • 17
  • 30