Registry / data / mplcursors

mplcursors

JSON →
library0.7.1pypypi✓ verified 23d ago

mplcursors provides interactive data selection cursors for Matplotlib. It is inspired by mpldatacursor, offering a simplified API to add dynamic tooltips and annotations to plots, enhancing data exploration. The library is actively maintained, with its current version 0.7.1 released in March 2026.

pip install mplcursors
INSTALL
IMPORT
SIG · MPLCURSORS
M
mplcursors
datapythonv0.7.1
Install
7.5s avg
Import
2608ms
Disk
181MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.658s · 178.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 7.5s · import 2.558s · 170MB
181MB installed
● package 181MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cursor
from mplcursors import cursor
The primary function to enable interactive cursors on a plot or specific artists.

This basic example demonstrates how to create a simple Matplotlib plot and then apply `mplcursors.cursor()` to enable interactive data selection and draggable annotations on the plotted lines. A left click creates a draggable annotation, and a right click removes it.

import matplotlib.pyplot as plt import numpy as np import mplcursors # Generate some data data = np.outer(range(10), range(1, 5)) fig, ax = plt.subplots() lines = ax.plot(data) ax.set_title( "Click somewhere on a line.\nRight-click to deselect.\n" "Annotations can be dragged." ) # Enable interactive cursors on the plotted lines mplcursors.cursor(lines, hover=False) # hover=False means click to activate plt.show()
Debug
Known issues
breakingThe `index` attribute of a `Selection` object changed its path. It is now a direct attribute of `Selection`, not `Selection.target.index`.
fix
Update code accessing `Selection.target.index` to `Selection.index`. `Selection.target.index` was deprecated in 0.5 and will be removed.
affects: 0.5 and later
breakingWhen using the `MPLCURSORS` environment variable for global configuration, explicit registration in `mpl.rcParams['figure.hooks']` is now required.
fix
Add `"mplcursors:install"` to `mpl.rcParams["figure.hooks"]` for global `MPLCURSORS` environment variable activation (requires Matplotlib>=3.7).
affects: 0.7 and later
gotchaAnnotations may not display correctly or disappear when using Matplotlib's animation blitting mode due to conflicts in artist drawing control.
fix
Avoid using `mplcursors` with Matplotlib's blitting-enabled animations, or consider alternative approaches for interactivity in such scenarios.
affects: All versions
gotchaArtists added to the figure *after* the initial figure draw (e.g., in interactive sessions or callbacks not using `pyplot` directly) may not be picked up by `mplcursors` by default.
fix
Ensure all desired artists are present when `mplcursors.cursor()` is called, or explicitly pass a list of artists/axes to `mplcursors.cursor()` including dynamically added ones.
affects: All versions
gotchaThere have been known incompatibilities with specific Matplotlib versions (e.g., Matplotlib 3.10.3 was marked incompatible in `mplcursors` 0.7, and 3.7.1 in 0.5.3).
fix
Consult the `mplcursors` changelog or documentation for specific Matplotlib compatibility requirements. Upgrade or downgrade Matplotlib if encountering issues.
affects: Various, depending on `mplcursors` and `matplotlib` versions
Errors
Common errors & fixes
ImportError: No module named 'mplcursors'
The 'mplcursors' library is not installed in the Python environment.
fix
Install the library using pip: 'pip install mplcursors'.
AttributeError: module 'mplcursors' has no attribute 'cursor'
The 'mplcursors' module is not correctly imported or the function 'cursor' is not available.
fix
Ensure correct import with 'import mplcursors' and verify the function's availability in the module.
TypeError: 'NoneType' object is not iterable
The 'mplcursors.cursor()' function is called with an invalid or NoneType argument.
fix
Pass a valid Matplotlib artist or list of artists to 'mplcursors.cursor()'.
ValueError: Invalid annotation_positions parameter
The 'annotation_positions' parameter in 'mplcursors.cursor()' is set incorrectly.
fix
Provide a valid list of dictionaries with correct keys for 'annotation_positions'.
RuntimeError: Event loop is already running
Attempting to use 'mplcursors' in an environment where the event loop is already active, such as Jupyter Notebook.
fix
Use '%matplotlib notebook' or '%matplotlib widget' in Jupyter Notebook to enable interactive plots.
Upgrade
Version history
0.7.1latest on PyPI · released Mar 18, 2026
Audit
Dependencies
matplotlibrequiredCore dependency for plotting, requires Matplotlib>=3.1.
pythonrequiredRequires Python version >=3.7.
numpyoptionalOften used with Matplotlib for data generation.
Agent activity
1 hits · last 30 days
Resources