Dears all,
I solved the issue changing the command
'ani = animation.FuncAnimation(fig, run, data_gen, blit=True, interval=5,repeat=True) ’
and my Open Physics Laboratory works fine!!
Thanks a bunch far all!
Bye,
Marco
···
Il giorno mar 16 lug 2019 alle ore 18:02 [email protected] ha scritto:
Send Matplotlib-users mailing list submissions to
[email protected]To subscribe or unsubscribe via the World Wide Web, visit
[https://mail.python.org/mailman/listinfo/matplotlib-users](https://mail.python.org/mailman/listinfo/matplotlib-users)or, via email, send a message with subject or body ‘help’ to
[email protected]You can reach the person managing the list at
[email protected]When replying, please edit your Subject line so it is more specific
than “Re: Contents of Matplotlib-users digest…”
Today’s Topics:
- Help request serila data plot, Ubuntu 18 (Animatore. TRPS03000X)
Message: 1
Date: Mon, 15 Jul 2019 21:05:16 +0200
From: “Animatore. TRPS03000X” [email protected]
Subject: [Matplotlib-users] Help request serila data plot, Ubuntu 18
Message-ID:
<CACxvrmM6QZKih4d5Zr_8s38Usf2kbEfhwkqw=uo_-vD6AoN6hw@mail.gmail.com>Content-Type: text/plain; charset=“utf-8”
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 deidati")
xdata, ydata = [], [] ser = serial.Serial('/dev/ttyACM0', 9600) while (False): pre=ser.readline() pre=ser.readline() 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 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 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: a = ser.readline() 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-0001.html>
Subject: Digest Footer
Matplotlib-users mailing list
https://mail.python.org/mailman/listinfo/matplotlib-users
End of Matplotlib-users Digest, Vol 48, Issue 2