Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FancyArrowPatch picker fails depending on arrowstyle #8384

@lejar

Description

@lejar

Bug report

Bug summary

The picker of FancyArrowPatch will not work with some arrow styles (see included example). Certain arrow styles will cause the picker to produce a pick event if the user clicks anywhere to the left of the arrow.

Code for reproduction

from matplotlib import pyplot as plt
from matplotlib import patches


def pick_event(event):
    print("PICK", event.artist)


def main():
    fig = plt.figure()
    axes = fig.add_subplot(111)
    axes.set_xlim((0, 10))
    axes.set_ylim((0, 10))

    arrow = patches.FancyArrowPatch(
        (8, 2),
        (9, 3),
        # Uncommenting this will make the pick event be triggered every time I
        # click to the left of the arrow.
        # arrowstyle='-|>',
    )
    # Same thing happens with arrow.set_picker(True)
    arrow.set_picker(4)

    fig.canvas.mpl_connect('pick_event', pick_event)
    axes.add_patch(arrow)
    plt.show()


if __name__ == '__main__':
    main()

Actual outcome
(With the arrowstyle line uncommented)
A pick event is always triggered when clicking to the left of the arrow.

PICK FancyArrowPatch(8,2->9,3)
PICK FancyArrowPatch(8,2->9,3)
PICK FancyArrowPatch(8,2->9,3)
PICK FancyArrowPatch(8,2->9,3)
PICK FancyArrowPatch(8,2->9,3)

Expected outcome
The pick event is not triggered unless the user actually clicks on the arrow.

Matplotlib version
I tested this with two versions of matplotlib:

  • version 2.0.0 installed via pip 9.0.1 using Python 2.7.12 included in ubuntu
  • version 1.5.3 built from source using Python 2.7.11 built from source

OS information:

$ uname -a
Linux 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions