displaying coords

Hello,

I recently worked on displaying plot coordinates from the example code 'coord_demo.py' so that I now have a script that should provide the following features:

  - coords are displayed either when clicking a mouse button or when stopping the mouse cursor in the plot for a given time (based on a timer)

  - coords can be displayed in the console or directly in the figure (a kind of balloon)

  - displayed coords are the nearest plot point coords provided the number of point distances to compute between mouse and curves is low enough to preserve resources, coords are only displayed if the smallest computed distance is "small" enough

  - coords displaying is activated by calling a unique function, its args define the type of event that triggers coords displaying and the callback that renders these coords (users can then provide their own one)

The callback that displays coords in a balloon uses the 'text' function of matplotlib.matlab such that this feature shouldn't rely on any backend.

Unfortunately things don't work for all backends. The results are the following:
    console displaying balloon displaying
    ------------------ ------------------
WXAgg OK OK
TkAgg OK hangs
GTKAgg nothing happens nothing happens

Note that I never tried in an interactive session and I currently use matplotlib 0.62.4. In case some people are interested in having a look at my code, I attached it. This is a module that can be run as a standalone script for testing.

If things finally get work, I plan to add a backend-independent "cross hair" as 'wxcursor_demo.py' does using lines, and to highlight the nearest point in the figure by changing its color and/or its marker (but I still don't know how to!). I also wonder about the opportunity to add a toolbar button for this kind of tool. This would certainly require further improvements since my script seems to interact with the zoom tool callback while drawing the rectangle with the mouse. Moreover I only tested it for a single plot at the moment.

JM. Philippe

coords.py (5.54 KB)