[Matplotlib-devel] feature request

Antony Lee antony.lee at berkeley.edu
Thu Nov 2 13:47:19 EDT 2017


Hi,

mplcursors should work just fine with a custom pyqt widget (I often write
pyqt apps as well).

To pin the bottom right text, e.g. the following works:

from matplotlib import pyplot as plt
import mplcursors

fig, ax = plt.subplots()
ax.plot([1, 2])
# By default, keep the status bar text cleared.
fig.canvas.mpl_connect(
    "motion_notify_event",
    lambda event: fig.canvas.toolbar.set_message(""))
# If the cursor matches, update the status bar text.
mplcursors.cursor(hover=True).connect(
    "add",
    lambda sel: fig.canvas.toolbar.set_message(
        sel.annotation.get_text().replace("\n", "  ")))
plt.show()


I will probably add a similar example to the mplcursors doc.

Antony

2017-11-02 5:50 GMT-07:00 Rogier Delporte <rogier.delporte at gmail.com>:

> Hi
>
> I had a quick look at mplcursors and it's very close to what I want. I'm
> not sure I'll be able to use it in combination with a custom pyqt
> matplotlib widget.
>
> I think it would be a very nice feature if this could be integrated right
> into matplotlib in such a way that the cursor readout in the bottom right
> corner snaps(of course it would be made optional) to the nearest data
> point. Unfortunately, I'm too much of a noob to implement this myself, but
> I'd like to request this feature be put on one of the todo-lists.
>
> Thanks for the great library!
>
> Rogier Delporte
>
>
>
> On Sat, Sep 30, 2017 at 8:45 AM, Rogier Delporte <
> rogier.delporte at gmail.com> wrote:
>
>> Thanks, I'll check it out.
>>
>> Op 29 sep. 2017 11:35 p.m. schreef "Antony Lee" <antony.lee at berkeley.edu
>> >:
>>
>> Hi,
>>> You may also want to look at mplcursors's hover mode (
>>> https://mplcursors.readthedocs.io/en/latest/examples/hover.
>>> html#sphx-glr-examples-hover-py).
>>> Antony
>>>
>>> 2017-09-29 14:24 GMT-07:00 Jody Klymak <jklymak at uvic.ca>:
>>>
>>>> Hi Rogier,
>>>>
>>>> You can already do this by writing a format_coord function and setting
>>>> ax.format_coord property of the axis with your data in it.
>>>>
>>>> http://matplotlib.org/examples/api/image_zcoord.html
>>>>
>>>> Cheers, Jody
>>>>
>>>> On 29 Sep 2017, at 6:57, Rogier Delporte wrote:
>>>>
>>>> Dear maintainer(s)
>>>> Dear developpers
>>>>
>>>> I would like to request a new matplotlib feature. The current version of
>>>> matplotlib shows the coordinates of the cursor in the bottom right
>>>> corner.
>>>> It would be great if some option or mode could be added which snaps the
>>>> cursor to data points. This would take some guesswork out of reading a
>>>> plot
>>>> with a lot of points.
>>>>
>>>> I know this feature is similar to the mpldatacursor toolkit, but
>>>> mpldatacursor does not provide a smooth and fast way to pinpoint a data
>>>> point.
>>>>
>>>> I hope someone would like to implement this feature, because I don't
>>>> have
>>>> sufficient programming skills to implement this myself.
>>>>
>>>> Thanks for the awesomeness that is matplotlib!
>>>>
>>>> Rogier
>>>> _______________________________________________
>>>> Matplotlib-devel mailing list
>>>> Matplotlib-devel at python.org
>>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>>>
>>>>
>>>> _______________________________________________
>>>> Matplotlib-devel mailing list
>>>> Matplotlib-devel at python.org
>>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>>>
>>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20171102/044e0649/attachment.html>


More information about the Matplotlib-devel mailing list