Skip to content Skip to sidebar Skip to footer

How Can I Pass Parameters To On_key In Fig.canvas.mpl_connect('key_press_event', On_key)?

I have a function def on_key(event): Which I call from fig.canvas.mpl_connect('key_press_event', on_key) I would like to pass the parameters plt1, plt2, plt3 to on_key... how c

Solution 1:

Probably

defon_key(event, arg1, arg2, arg3):

and

fig.canvas.mpl_connect('key_press_event', lambda event: on_key(event, plt1, plt2, plt3))

or as list

defon_key(event, args_list):

and

fig.canvas.mpl_connect('key_press_event', lambda event: on_key(event, [plt1, plt2, plt3]))

Post a Comment for "How Can I Pass Parameters To On_key In Fig.canvas.mpl_connect('key_press_event', On_key)?"