How to select area within a plot (Python) and extract the data within the area

Viewed 10880

I am currently working with a dataset that includes signals with a duration of around 10 seconds and a sampling time of 0.1 seconds. My goal is to extract a specific part of this data and save it into a python dictionary. The relevant part is about 4 seconds long.

Ideally this is what I would like to do:

  1. Plot the whole 10 seconds of data.

  2. Mark the relevant part of the signals for example with a bounding box.

  3. Extract the data within the bounding box after closing the plot window or pushing a button.

  4. Go back to 1. and take new data.

I saw that matplotlib has the ability to draw patches and extract the data points within the patch. Is it maybe possible to add a patch to the plot after the plot was created (after the plt.show() command was executed)?

Thank you in advance and best regards,

Manuel

1 Answers
Related