ABCD ABCD - 29 days ago 12
Python Question

Matplotlib Event handling

I was playing with this example code for a while now.
http://matplotlib.org/examples/event_handling/poly_editor.html


  1. I want to get a editable line instead of a polygon. I got it done by

    xs = np.arange(0,1,0.1)

    ys = xs*2.0

    but still im getting a filled polygon. How can i just get a line ?



Output


  1. I want to add a button to this so that when I press the button updated x,y pairs will be printed.



How can I get this done.

Thanks much in advance.

Answer

Use this statement in place of the similar one in the code.

poly = Polygon(list(zip(xs, ys)), animated=True, fc='w')

I can't help with adding a button. However, you could put the part of the code that creates the plot in a loop that prints what you want after plt.show(), and includes an input statement offering the user another opportunity to use the facility before exiting.

Comments