Files
JustTwirk/ploting.py
2025-08-25 19:37:48 +02:00

26 lines
560 B
Python

import matplotlib.pyplot as plt
import queue
data_queue = queue.Queue()
x_data, y_data = [], []
fig, ax = plt.subplots()
line, = ax.plot([], [], 'r-')
def init():
ax.set_xlim(0, 100)
ax.set_ylim(0, 10)
return line,
def update(frame):
# sprawdzamy, czy są nowe dane w kolejce
while not data_queue.empty():
value = data_queue.get()
x_data.append(len(x_data))
y_data.append(value)
if len(x_data) > 100:
x_data.pop(0)
y_data.pop(0)
line.set_data(x_data, y_data)
return line,