Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: MultiCursor in inset axes #26225

Closed
jlocatelli74 opened this issue Jun 30, 2023 · 2 comments
Closed

[Bug]: MultiCursor in inset axes #26225

jlocatelli74 opened this issue Jun 30, 2023 · 2 comments

Comments

@jlocatelli74
Copy link

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

@jlocatelli74
Copy link
Author

A better video

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

@anntzer
Copy link
Contributor

anntzer commented Jul 4, 2023

AFAICT this is fixed as of master, most likely since #25555. Feel free to reopen if there's a further issue.

@anntzer anntzer closed this as completed Jul 4, 2023
@anntzer anntzer added this to the v3.8.0 milestone Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants