I've been using this code for a while and it works great.

I wonder if there is a way to close the serial port so there is no need to unplug and plug again the usb cable between experiments. I tried with serial.Serial("COM3").close() but it doesn't work.

Also, some suggestion about how can the plot only show the current subplot and not both? (voltage and current ).

I would appreciate any help with this.

EDIT: I solved it restarting the kernel at the end of the code with os.exit(0)