Я хочу построить график, используя matplotlib. Я чувствую данные от датчика и помещаю эти данные в файл Excel. но я не могу получить желаемый результат.
я прилагаю ссылку пример кода здесь.
Также я прилагаю свой код, который я изменил. Может ли кто-нибудь помочь в этом вопросе
import datetime as dt
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import xlrd
hsif = pd.read_excel('C:\\Users\\Hp\\Desktop\\Sensor.xlsx','Sheet2', skiprows=3)
data = hsif.columns.values[3]
print(data)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
xs = []
ys = []
# This function is called periodically from FuncAnimation
def animate(i, xs, ys):
# Read data from sensor
temp_c = data
# Add x and y to lists
xs.append(dt.datetime.now().strftime('%H:%M '))
ys.append(temp_c)
# Limit x and y lists to 20 items
xs = xs[-20:]
ys = ys[-20:]
# Draw x and y lists
ax.clear()
ax.plot(xs, ys)
# Format plot
plt.xticks(rotation=45, ha='right')
plt.subplots_adjust(bottom=0.30)
plt.title('Call OI over Time')
plt.ylabel('Numbers')
# Set up plot to call animate() function periodically
ani = animation.FuncAnimation(fig, animate, fargs=(xs, ys), interval=1000)
plt.show()