# [Matplotlib-users] Help request serila data plot, Ubuntu 18

Animatore. TRPS03000X animatore.trps03000x at didasca.org
Mon Jul 15 15:05:16 EDT 2019

```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

matplotlib.use("Qt5Agg")

import numpy as np

import matplotlib.pyplot as plt

import matplotlib.animation as animation

from time import sleep

import serial

import time

fine="c"

pre="ciao"

while (fine != "f"):

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

xdata, ydata = [], []

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

while (False):

prec = float(pre)

y=prec

fig, ax = plt.subplots()

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

ax.set_ylim(0, 90)

ax.set_xlim(0, 10)

ax.grid()

def data_gen():

t=0

y=0

cnt=0

p=0

while (True)&(t < 10):

y = float(a)

if (y != 0) :

t = (time.time() - start)

t = float(t)

yield t, y

def run(data):

t,y = data

xdata.append(t)

ydata.append(y)

ax.figure.canvas.draw()

line.set_data(xdata, ydata)

return line,

data_gen.t = 0

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

if True:

y = float(a)

start = time.time()

ani = animation.FuncAnimation(fig, run, data_gen, blit=True,
interval=5,repeat=False)

plt.show()

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: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190715/32c8e462/attachment.html>
```