(event)
return dict(x=x, y=y)
Get information for a pick event on a Line2D artist (as created with
    ``plot``.)

    This will yield x and y values that are interpolated between vertices
    (instead of just being the position of the mouse) or snapped to the nearest
    vertex if only the vertices are drawn.

    Parameters
    -----------
    event : PickEvent
        The pick event to process

    Returns
    --------
    props : dict
        A dict with keys: x & y
Get information for a pick event on a Line2D artist (as created with
    ``plot``.)
Get information for a pick event on a Line2D artist ( as created with plot . )
def line_props(event):
    """
    Get information for a pick event on a Line2D artist (as created with
    ``plot``.)

    This will yield x and y values that are interpolated between vertices
    (instead of just being the position of the mouse) or snapped to the nearest
    vertex if only the vertices are drawn.

    Parameters
    -----------
    event : PickEvent
        The pick event to process

    Returns
    --------
    props : dict
        A dict with keys: x & y
    """
    xclick, yclick = event.mouseevent.xdata, event.mouseevent.ydata
    i = event.ind[0]
    xorig, yorig = event.artist.get_xydata().T

    # For points-only lines, snap to the nearest point.
    linestyle = event.artist.get_linestyle()
    if linestyle in ['none', ' ', '', None, 'None']:
        return dict(x=xorig[i], y=yorig[i])

    # ax.step is actually implemented as a Line2D with a different drawstyle...
    xs_data = xorig[max(i - 1, 0) : i + 2]
    ys_data = yorig[max(i - 1, 0) : i + 2]
    drawstyle = event.artist.drawStyles[event.artist.get_drawstyle()]
    if drawstyle == "_draw_lines":
        pass
    elif drawstyle == "_draw_steps_pre":
        xs_data = _interleave(xs_data, xs_data[:-1])
        ys_data = _interleave(ys_data, ys_data[1:])
    elif drawstyle == "_draw_steps_post":
        xs_data = _interleave(xs_data, xs_data[1:])
        ys_data = _interleave(ys_data, ys_data[:-1])
    elif drawstyle == "_draw_steps_mid":
        mid_xs = (xs_data[:-1] + xs_data[1:]) / 2
        xs_data = _interleave(xs_data, np.column_stack([mid_xs, mid_xs]))
        ys_data = _interleave(
            ys_data, np.column_stack([ys_data[:-1], ys_data[1:]]))
    else:
        raise ValueError(
            "Unknown drawstyle: {}".format(event.artist.get_drawstyle()))
    # The artist transform may be different from the axes transform (e.g.,
    # axvline/axhline)
    artist_transform = event.artist.get_transform()
    axes_transform = event.artist.axes.transData
    xs_screen, ys_screen = (
        artist_transform.transform(
            np.column_stack([xs_data, ys_data]))).T
    xclick_screen, yclick_screen = (
        axes_transform.transform([xclick, yclick]))
    x_screen, y_screen = _interpolate_line(xs_screen, ys_screen,
                                           xclick_screen, yclick_screen)
    x, y = axes_transform.inverted().transform([x_screen, y_screen])

    return dict(x=x, y=y)
def line_props ( event ) : xclick , yclick = event . mouseevent . xdata , event . mouseevent . ydata i = event . ind [ 0 ] xorig , yorig = event . artist . get_xydata ( ) . T # For points-only lines, snap to the nearest point. linestyle = event . artist . get_linestyle ( ) if linestyle in [ 'none' , ' ' , '' , None , 'None' ] : return dict ( x = xorig [ i ] , y = yorig [ i ] ) # ax.step is actually implemented as a Line2D with a different drawstyle... xs_data = xorig [ max ( i - 1 , 0 ) : i + 2 ] ys_data = yorig [ max ( i - 1 , 0 ) : i + 2 ] drawstyle = event . artist . drawStyles [ event . artist . get_drawstyle ( ) ] if drawstyle == "_draw_lines" : pass elif drawstyle == "_draw_steps_pre" : xs_data = _interleave ( xs_data , xs_data [ : - 1 ] ) ys_data = _interleave ( ys_data , ys_data [ 1 : ] ) elif drawstyle == "_draw_steps_post" : xs_data = _interleave ( xs_data , xs_data [ 1 : ] ) ys_data = _interleave ( ys_data , ys_data [ : - 1 ] ) elif drawstyle == "_draw_steps_mid" : mid_xs = ( xs_data [ : - 1 ] + xs_data [ 1 : ] ) / 2 xs_data = _interleave ( xs_data , np . column_stack ( [ mid_xs , mid_xs ] ) ) ys_data = _interleave ( ys_data , np . column_stack ( [ ys_data [ : - 1 ] , ys_data [ 1 : ] ] ) ) else : raise ValueError ( "Unknown drawstyle: {}" . format ( event . artist . get_drawstyle ( ) ) ) # The artist transform may be different from the axes transform (e.g., # axvline/axhline) artist_transform = event . artist . get_transform ( ) axes_transform = event . artist . axes . transData xs_screen , ys_screen = ( artist_transform . transform ( np . column_stack ( [ xs_data , ys_data ] ) ) ) . T xclick_screen , yclick_screen = ( axes_transform . transform ( [ xclick , yclick ] ) ) x_screen , y_screen = _interpolate_line ( xs_screen , ys_screen , xclick_screen , yclick_screen ) x , y = axes_transform . inverted ( ) . transform ( [ x_screen , y_screen ] ) return dict ( x = x , y = y )