Most matplotlib objects have a remove() function (I think it is inherited from Artist ). Just name it the object you want to delete.
Edit:
If you
dc = DataCursor(...)
Python does not have the concept of 'private' attributes, so you can just get inside the object and cause the annotation to be deleted. See the class textbook for more details.
The downside of this is that you now have an odd state object. If you have other links to it, they can behave badly. If you want to keep the DataCursor object around, you can change the annotation object using its set_* or change its visibility to temporarily hide it ( doc )
source share