Help request serila data plot, Ubuntu 18

Dear matplot users,

I have installed Ubuntu 18 on my computer and Matplotlib, I use it to graph
position vs. time of moving objects by serial data.

The python script is the following:

import matplotlib


import numpy as np

import matplotlib.pyplot as plt

import matplotlib.animation as animation

from time import sleep

import serial

import time



while (fine != "f"):

     raw_input("\n\n\n Premi Enter per far partire la registrazione dei

     xdata, ydata = [], []

     ser = serial.Serial('/dev/ttyACM0', 9600)

     while (False):



     prec = float(pre)


     fig, ax = plt.subplots()

     line, = ax.plot([], [], lw=2)

     ax.set_ylim(0, 90)

     ax.set_xlim(0, 10)


     def data_gen():





        a = ser.readline()

        while (True)&(t < 10):

            a = ser.readline()

            y = float(a)

            if (y != 0) :

                t = (time.time() - start)

                t = float(t)

                yield t, y

     def run(data):

         t,y = data




        line.set_data(xdata, ydata)

       return line,

data_gen.t = 0

while (abs(y-prec) < 2):

    if True:

         a = ser.readline()

         y = float(a)

         start = time.time()

ani = animation.FuncAnimation(fig, run, data_gen, blit=True,

stop =0

fine=raw_input("Premi f per finire :")

It works fine, but after the plotting (10 seconds), there is a problem, I
cannnot use the tools of the matplot window, i.e. when I try to zoom, after
selecting the area, the plot desappear.

Can you help me?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>