Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: MultiCursor in inset axes #26225

Copy link
Copy link
Closed
@jlocatelli74

Description

@jlocatelli74
Issue body actions

Bug summary

When we using a MultiCursor on an axes and an inset axis, the cursor follow the mouse only on the main axes. When the mouse cursor move on the inset axes the cursor don't move.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import MultiCursor

# Fixing random state for reproducibility
np.random.seed(19680801)

# some random data
x = np.random.randn(1000)
y = np.random.randn(1000)


def scatter_hist(x, y, ax, ax_histx, ax_histy):
    # no labels
    ax_histx.tick_params(axis="x", labelbottom=False)
    ax_histy.tick_params(axis="y", labelleft=False)

    # the scatter plot:
    ax.scatter(x, y)

    # now determine nice limits by hand:
    binwidth = 0.25
    xymax = max(np.max(np.abs(x)), np.max(np.abs(y)))
    lim = (int(xymax/binwidth) + 1) * binwidth

    bins = np.arange(-lim, lim + binwidth, binwidth)
    ax_histx.hist(x, bins=bins, label="X")
    ax_histy.hist(y, bins=bins, orientation='horizontal', label="Y")
    
# Create a Figure, which doesn't have to be square.
fig = plt.figure(layout='constrained')
# Create the main axes, leaving 25% of the figure space at the top and on the
# right to position marginals.
ax = fig.add_gridspec().subplots()
# The main axes' aspect can be fixed.

#ax.set(aspect=1)
# Create marginal axes, which have 25% of the size of the main axes.  Note that
# the inset axes are positioned *outside* (on the right and the top) of the
# main axes, by specifying axes coordinates greater than 1.  Axes coordinates
# less than 0 would likewise specify positions on the left and the bottom of
# the main axes.
ax_histx = ax.inset_axes([0, -0.25, 1, 0.12], sharex=ax)
ax_histy = ax.inset_axes([-0.25, 0, 0.12, 1], sharey=ax)
ax_plus = ax.inset_axes([1.05, 0, 0.02, 1])
# Draw the scatter plot and marginals.
scatter_hist(x, y, ax, ax_histx, ax_histy)


multi1 = MultiCursor(None, (ax, ax_histx), useblit=False, horizOn=False, vertOn=True, color='r', lw=1)
multi2 = MultiCursor(None, (ax_histy, ax), useblit=False, horizOn=True, vertOn=False, color='r', lw=1)

#ax.set_aspect(0.5)

plt.show()

Actual outcome

simplescreenrecorder-2023-06-30_16.45.57.mp4

Expected outcome

The cursor move following mouse for all axis.

Additional information

No response

Operating system

Ubuntu

Matplotlib Version

3.1.6

Matplotlib Backend

QtAgg

Python version

3.10.6

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.