Interactive data plotting Matplotlib

Hi

I have a text file containing experimental data obtained over the course of two years. The data were obtained on a daily basis. Having inspected some of the data in Excel (there are over 15 000 points), I noticed that there are a couple
of points that should not be included in the final data analysis. I want to write a python programme that does the following:

Creates a plot of the data taken on day 1.

Allows the user to click on the “bad data” and then writes these points to either a text file or a list(which can then be written to a text file at a later stage).

If all the bad data points have been selected ( or if there are no bad points) then, following an indication by the user (i.e. either via a key press event or the user clicking outside the plot area), plot the data of the next day.

What I want the programme to do is repeat the above steps until it reaches the end of the data file and then at the end, I want a text file containing the information of the bad points which I can then remove from the main data file at
a later stage. I know that one way of obtaining the information of the bad points is to use event handling, especially the ‘button_press_event’ and creating a MouseMonitor class. What I’m specifically having trouble with is figuring out how I can get the
programme to run through all the data, all the while keeping the ‘button_press_event’ connected/active and writing all the bad data to a text file. Only at the end of all the data, do I want to disconnect the ‘button_press_event’ (unless of course there is
a better way of doing this).

Any help will be greatly appreciated.

Thanks

Pat