Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Closed
Description
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
importmatplotlib.pyplotaspltimportnumpyasnp# Sample datax=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 legendlegend=ax.legend()legend.set_draggable(True)# Add a draggable annotationann=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
Labels
No labels