As linked by @ThomasKühn, the answer is to create a software debounce. There are several ways to go about it, and the solution probably depends on your application (are you using a GUI, what backend, etc.) To be as agnostic as possible, I've implemented my solution using a one-shot thread from the threading module.
import threading
import matplotlib.pyplot as plt
DEBOUNCE_DUR = 0.25
t = None
def on_press(event):
global t
if t is None:
t = threading.Timer(DEBOUNCE_DUR, on_singleclick, [event])
t.start()
if event.dblclick:
t.cancel()
on_dblclick(event)
def on_dblclick(event):
global t
print("You double-clicked", event.button, event.xdata, event.ydata)
t = None
def on_singleclick(event):
global t
print("You single-clicked", event.button, event.xdata, event.ydata)
t = None
fig, ax = plt.subplots()
cid = fig.canvas.mpl_connect('button_press_event', on_press)
plt.show()