This script:
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
def fAccept(_):
print(f'accepted')
def onclick(event):
print(f'click {event.xdata, event.ydata}')
fig, ax = plt.subplots()
fig.subplots_adjust(bottom=0.2)
fig.canvas.mpl_connect('button_press_event', onclick)
axAccept = fig.add_axes([0.7, 0.05, 0.1, 0.075])
bAccept = Button(axAccept, 'Accept')
bAccept.on_clicked(fAccept)
plt.show()
displays
Clicking on bAccept button calls onclick callback. Is there a way to limit onclick callback to the top axis? Alternatively, is there a way to distinguish event coordinates (0.5, 0.5) at the center of bAccept button (green circle) from (0.5, 0.5) coordinates at the center of the upper axis (red circle)?
