Я не серьезный программист, просто фанат идей. Я создал этот скрипт. Он рисует график последних 60 строк из файла журнала, который получает данные от датчика вакуума через последовательное соединение, но проблема в том, что этот скрипт быстро увеличивает заполнение ОЗУ. Что с ним не так, что я делаю не так?
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import matplotlib
matplotlib.use('TkAgg')
import csv
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
plt.subplots_adjust(bottom=0.25)
filename = "loggedData.txt"
last_rows = 60
def update(i):
file_data = pd.read_csv(filename, skiprows = 2, delimiter=",",
header=None, parse_dates=True, usecols=[0, 1])
time_data=(file_data[0].tail(last_rows))
vacuum_data=(file_data[1].tail(last_rows))
# print(xdata)
# print(ydata)
# ax1.clear()
plt.cla()
ax1.plot(time_data,vacuum_data)
fig.autofmt_xdate(rotation=45)
ax1.set_xlabel('Measurement time')
ax1.set_ylabel('Vacuum (Torr)')
plt.yscale('log')
ax1.grid(which='major', color='#CCCCCC', linestyle='--')
ax1.grid(which='minor', color='#CCCCCC', linestyle=':')
ani = animation.FuncAnimation(fig, update, interval=1000)
plt.show()