I'm plotting around 250k points with matplotlib so naturally when I'm moving my mouse to use/refresh a cursor widget, it lags a lot. Therefore, I was looking for one way to optimize the use of this widget and I thought of refreshing the cursor on click to reduce the number of freezes. I saw this extract from the matplotlib documentation and other examples of click events, however I didn't manage to find more information about specifically linking the cursor refresh to the mouse click event.
Is it even possible?
Screenshot of the graph and the cursor:
Code used to plot the graph and add the cursor:
import matplotlib.pyplot as plt
from matplotlib.widgets import Cursor
fig, ax = plt.subplots(figsize=(20, 8), num="Original Signal")
thismanager = plt.get_current_fig_manager()
thismanager.window.wm_iconbitmap("icon.ico")
thismanager = plt.get_current_fig_manager().window.state('zoomed')
plt.plot(Time, Ampl)
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.tight_layout()
plt.savefig(filepath[:-4] + "_OriginalSignal.jpeg")
cursor = Cursor(ax, color='r', horizOn=True, vertOn=True)
print('Original Signal file created: "', filepath[:-4], '_OriginalSignal.jpeg".', sep="")