Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 can I do this?

like image 712
baconwichsand Avatar asked Jul 25 '14 17:07

baconwichsand


1 Answers

Probably

def on_key(event, arg1, arg2, arg3):

and

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

or as list

def on_key(event, args_list):

and

fig.canvas.mpl_connect('key_press_event', lambda event: on_key(event, [plt1, plt2, plt3]))
like image 114
furas Avatar answered Sep 23 '22 02:09

furas