File: nondraggable.py

package info (click to toggle)
mplcursors 0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 400 kB
  • sloc: python: 1,915; makefile: 14; sh: 9
file content (24 lines) | stat: -rw-r--r-- 647 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Using multiple annotations and disabling draggability via signals
=================================================================

By default, each `Cursor` will ever display one annotation at a time.  Pass
``multiple=True`` to display multiple annotations.

Annotations can be made non-draggable by hooking their creation.
"""

import matplotlib.pyplot as plt
import numpy as np
import mplcursors

data = np.outer(range(10), range(1, 5))

fig, ax = plt.subplots()
ax.set_title("Multiple non-draggable annotations")
ax.plot(data)

mplcursors.cursor(multiple=True).connect(
    "add", lambda sel: sel.annotation.draggable(False))

plt.show()