X Tutup
Skip to content

Draggable annotation position wrong with negative x/y #4295

@wilywampa

Description

@wilywampa

Any draggable annotation is displayed in the wrong position after dragging (i.e. nowhere near the mouse cursor) if either of the initial XY coordinates is negative. Minimal example:
drag

import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcdefaults()
mpl.rcParams['toolbar'] = 'none'

plt.figure(figsize=(5, 2))
plt.plot(range(-10, 10))
an1 = plt.annotate(s='good', xy=(15, 5), bbox={'alpha': 0.5})
an1.draggable()
an2 = plt.annotate(s='bad', xy=(5, -5), bbox={'alpha': 0.5})
an2.draggable()
plt.show()

It is caused by the reference coordinates being set apparently incorrectly here: https://github.com/matplotlib/matplotlib/blob/8a270fcc64197ee00c818ec8f9ccc9f0e884828a/lib/matplotlib/text.py#L1597-1605

Using matplotlib 1.4.3 with various OSes/backends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup