matplotlib — interactively select points or locations?

前端 未结 3 1622
误落风尘
误落风尘 2020-12-24 02:40

In R, there is a function locator which is like Matlab\'s ginput where you can click on the figure with a mouse and select any x,y coordinate. In a

3条回答
  •  温柔的废话
    2020-12-24 03:07

    You may want to use a pick event :

    fig = figure()
    ax1 = fig.add_subplot(111)
    ax1.set_title('custom picker for line data')
    line, = ax1.plot(rand(100), rand(100), 'o', picker=line_picker)
    fig.canvas.mpl_connect('pick_event', onpick2)
    

    Tolerance set by picker parameter there:

    line, = ax1.plot(rand(100), 'o', picker=5)  # 5 points tolerance
    

提交回复
热议问题