How to use the mplcursors.HoverMode.Persistent function in mplcursors

To help you get started, we’ve selected a few mplcursors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anntzer / mplcursors / tests / test_mplcursors.py View on Github external
    "hover", [True, HoverMode.Persistent, 2, HoverMode.Transient])
def test_hover(ax, hover):
    l1, = ax.plot([0, 1])
    l2, = ax.plot([1, 2])
    cursor = mplcursors.cursor(hover=hover)
    _process_event("motion_notify_event", ax, (.5, .5), 1)
    assert len(cursor.selections) == 0  # No trigger if mouse button pressed.
    _process_event("motion_notify_event", ax, (.5, .5))
    assert cursor.selections[0].artist == l1
    _process_event("motion_notify_event", ax, (.5, 1))
    assert bool(cursor.selections) == (hover == HoverMode.Persistent)
    _process_event("motion_notify_event", ax, (.5, 1.5))
    assert cursor.selections[0].artist == l2