18

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,105
  • 1
  • 13
  • 30

1 Answers1

34

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
  • 119,752
  • 10
  • 94
  • 135