In MATLAB, one can use datacursormode
to add annotation to a graph when user mouses over. Is there such thing in matplotlib? Or I need to write my own event using matplotlib.text.Annotation
?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Late Edit / Shameless Plug: This is now available (with much more functionality) as
mpldatacursor
. Callingmpldatacursor.datacursor()
will enable it for all matplotlib artists (including basic support for z-values in images, etc).As far as I know, there isn't one already implemented, but it's not too hard to write something similar:
As it seems like at least a few people are using this, I've added an updated version below.
The new version has a simpler usage and a lot more documentation (i.e. a tiny bit, at least).
Basically you'd use it similar to this:
The main differences are that a) there's no need to manually call
line.set_picker(...)
, b) there's no need to manually callfig.canvas.mpl_connect
, and c) this version handles multiple axes and multiple figures.