Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Line2D.contains does not take drawstyle into account. #6447

Copy link
Copy link
Closed
@anntzer

Description

@anntzer
Issue body actions

See joferkington/mpldatacursor#36.
Briefly, Line2D.contains currently assumes that points in the line are connected by straight segments, thus ignoring drawstyle. Minimal example (edited from the event handling doc):

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('click on points')

line, = ax.plot(np.random.rand(10), picker=5, drawstyle="steps-pre")  # 5 points tolerance

def onpick(event):
    thisline = event.artist
    xdata = thisline.get_xdata()
    ydata = thisline.get_ydata()
    ind = event.ind
    points = tuple(zip(xdata[ind], ydata[ind]))
    print('onpick points:', points)

fig.canvas.mpl_connect('pick_event', onpick)

plt.show()

Clicking on the drawn line does not always trigger an event. Clicking on the not-drawn "straight" segments connecting the data points does.

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.