0
我有两个传感器的数据,我想要可视化。两个传感器只取0/1值。如何更改xaxis标签以显示时间序列,y轴应该有2个标签0和1,表示沿时间序列的传感器值。绘图传感器布尔数据matplotlib
import pandas as pd
import matplotlib.pyplot as plt
def drawgraph(inputFile):
df=pd.read_csv(inputFile)
fig=plt.figure()
ax=fig.add_subplot(111)
y = df[['sensor1']]
x=df.index
plt.plot(x,y)
plt.show()
如果您的数据设置正确,熊猫会自动绘制x轴与日期时间。试试'df.plot(x ='datetime',y ='data')'。 – lanery