joferkington / mpldatacursor

Interactive "data cursors" (a.k.a. annotation pop-ups) for matplotlib
MIT License
194 stars 47 forks source link

Add custom data to the cursor #39

Closed jondo closed 9 years ago

jondo commented 9 years ago

I have got data consisting of three columns: two coordinates x, yand a timestamp t. I am plotting only the coordinate data: plt.plot(x, y, '.').

Is it possible to also show the timestamp in the data cursor?

joferkington commented 9 years ago

Sure! That's the purpose of the point_labels kwarg.

However, there's one caveat. It will work fine with plot but requires something that matplotlib internally treats as a sequence, so it doesn't work with bar and a few other things that one might expect it to.

As a basic example, see this: https://github.com/joferkington/mpldatacursor/blob/master/examples/labeled_points_example.py

jondo commented 9 years ago

Thank you, that works great! Sorry for just browsing the README and not the examples or the class definition.

May I suggest an improvement? It would be nice to have an option to just show the first and last label in case of several data points at the same position (instead of listing all the labels). Edit: I filed this as https://github.com/joferkington/mpldatacursor/issues/40.