ABCD ABCD - 7 months ago 57
Python Question

Matplotlib Event handling

I was playing with this example code for a while now.

  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 ?


  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.


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, and includes an input statement offering the user another opportunity to use the facility before exiting.