Button and Mouse event

Hello.

In the following code, I would like to add two buttons. Is there an easy way to do that ?

Christophe

···

================================

import matplotlib.pyplot as plt

from matplotlib.widgets import Button

fig = plt.figure()

plt.axes(xlim = (0, 3), ylim = (0, 3))

def onclick(event):

print(event.xdata, event.ydata)

fig.canvas.mpl_connect(‘button_press_event’, onclick)

plt.show()

Does this example help?
http://matplotlib.org/examples/widgets/buttons.html

With the Button widget, you won’t need to do any mpl_connect calls, the widget takes care of that for you. Also, as a side note, the “button_press_event” does not refer to the button widgets, it refers to the mouse button.

Cheers!

Ben Root

···

On Sat, Sep 27, 2014 at 6:30 PM, Christophe Bal <projetmbc@…287…> wrote:

Hello.

In the following code, I would like to add two buttons. Is there an easy way to do that ?

Christophe

================================

import matplotlib.pyplot as plt

from matplotlib.widgets import Button

fig = plt.figure()

plt.axes(xlim = (0, 3), ylim = (0, 3))

def onclick(event):

print(event.xdata, event.ydata)

fig.canvas.mpl_connect(‘button_press_event’, onclick)

plt.show()


Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer

Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports

Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper

Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer

http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users