Python MATPLOTY轴未排序
我从串口获取数据并用matplotlib绘制。但有一个问题。这是因为我无法对y轴值进行排序Python MATPLOTY轴未排序,python,matplotlib,Python,Matplotlib,我从串口获取数据并用matplotlib绘制。但有一个问题。这是因为我无法对y轴值进行排序 import matplotlib.pyplot as plt import matplotlib.animation as animation from deneme_serial import serial_reader collect = serial_reader() fig = plt.figure() ax = fig.add_subplot(1, 1, 1) xs=[] ys=[]
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from deneme_serial import serial_reader
collect = serial_reader()
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
xs=[]
ys=[]
def animate(i, xs, ys):
xs = collect.collector()[0]
ys = collect.collector()[1]
ax.clear()
ax.plot(xs)
ax.plot(ys)
axes=plt.gca()
plt.xticks(rotation=45, ha='right')
plt.subplots_adjust(bottom=0.30)
plt.title('TMP102 Temperature over Time')
plt.ylabel('Temperature (deg C)')
ani = animation.FuncAnimation(fig, animate, fargs=(xs,ys), interval=1000)
plt.show()
下图是上述代码的结果
您忘记将字符串转换为数字。您忘记将字符串转换为数字。