Interactive data selection cursors for Matplotlib

0.7.1 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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()

view raw JSON →