19

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?

baconwichsand
  • 1,161
  • 2
  • 13
  • 31

1 Answers1

41

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]))
furas
  • 134,197
  • 12
  • 106
  • 148