Skip to content

[Bug]: Outline of draggable legends and annotations not respected #30378

@kaktus018

Description

@kaktus018

Bug summary

When adding draggable legends and annotations to a plot, the actual outline of them is not respected for a drag operation. Regardless of where you click & drag, every annotation and the legend is moved. This is identical to #30303 which has been closed.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

# Sample data
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)

fig, ax = plt.subplots()
line1, = ax.plot(x, y1, label='sin(x)')
line2, = ax.plot(x, y2, label='cos(x)')

# Add a draggable legend
legend = ax.legend()
legend.set_draggable(True)

# Add a draggable annotation
ann = ax.annotate(
    'Peak', xy=(np.pi/2, 1), xytext=(np.pi/2+1, 1.2),
    arrowprops=dict(facecolor='black', shrink=0.05),
    bbox=dict(boxstyle="round,pad=0.3", fc="yellow", alpha=0.5)
)
ann.draggable(True)

plt.title('Draggable Legend and Annotation')
plt.show()

Actual outcome

actual.behavior.mp4

Expected outcome

expected.behavior.mp4

Additional information

This problem happens with matplotlib version 3.10.3 and does not exist with version 3.10.1. I am using qtagg as backend (PySide6 version 6.9.1).

Operating system

Windows-11-10.0.26100-SP0

Matplotlib Version

3.10.3

Matplotlib Backend

qtagg

Python version

3.13.5

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy