You should read this tutorial.
Basically, you need to define a function that takes one argument eventand then attaches it to your figure canvas:
def open_new_figure(event):
if event.inaxes is not None:
ax = event.inaxes
cid = fig.canvas.mpl_connect('button_press_event', open_new_figure)
source
share