Hi all,

I have defined some shortcuts I often use using pylab.ginput(). I normally
do:

> fig = pylab.figure()

fig.canvas.mpl_connect('key_press_event', on_key)

with my "on_key" function being (simplified):

> def on_key(event):

    if (event.key == 'q'):

        sys.exit(0)

    elif (event.key == 'w'):

        pylab.close(pylab.gcf())

    elif (event.key == 'd'):

        print "Please click two points to get the distance and slope."

        points = pylab.ginput(n=2, show_clicks=True)

        [...]

        pylab.plot([points[0][0], points[1][0]], [points[0][1],
> points[1][1]],  '+r', lw=1.0)

        pylab.plot([points[0][0], points[1][0]], [points[0][1],
> points[1][1]],  '--r', lw=1.0)

        pylab.draw()


I'm plotting two markers where the user clicked and a line between them.

This works fine, except when there is multiple subplots. I can correctly
select points and get their position, but the plot commands will put the
markers+line in the last subplot. I tried using "pylab.gca().plot()" but
gca() always returns the last axes.

My question is, how can I plot on the axes the user clicked on?

Thank you!

N
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to