Removing picked line

Hi John,

John Hunter <jdh2358@...287...> writes:

If for some reason the built in pick_event is unsuitable, you can
create your own matplotlib.backend_bases.MouseEvent and call
line.contains(event) for each line you want to hit test.

Thank you, that works for me. But for some reason, the "y" coordinate is
inversed in Qt and matplotlib? I have to specify

def get_lines_at_point(self, point):
    mpl_event = MouseEvent('button_press_event', self,
                           point.x(), self.height() - point.y())

···

#########################
    ret =
    for line in self.axes.get_lines():
        picked, details = line.contains(mpl_event)
        if picked:
            ret.append(line)
    return ret

The other question that now remains is: how can I remove a line from an
axes?

Best regards

Ole

Hi John,

John Hunter <jdh2358@...287...> writes:

If for some reason the built in pick_event is unsuitable, you can
create your own matplotlib.backend_bases.MouseEvent and call
line.contains(event) for each line you want to hit test.

Thank you, that works for me. But for some reason, the "y" coordinate is
inversed in Qt and matplotlib? I have to specify

Yes, for mpl 0,0 is bottom, left whereas many GUI canvases call 0,0 top, left

The other question that now remains is: how can I remove a line from an
axes?

  ax.lines.remove(someline)
  fig.canvas.draw()

JDH

···

On Wed, Jun 10, 2009 at 9:04 AM, Ole Streicher<ole-usenet-spam@...361...> wrote:

See also

http://matplotlib.sourceforge.net/users/artists.html

which covers this and other useful things.

JDH

···

On Wed, Jun 10, 2009 at 9:11 AM, John Hunter<jdh2358@...287...> wrote:

The other question that now remains is: how can I remove a line from an
axes?

ax.lines.remove(someline)
fig.canvas.draw()