嘿,伙计们,我正在读一个Arduino的数据,处理它,并使用我发现的代码来尝试和现场绘制数据。我已经编辑了这段代码,使它能够处理两组数据,并且我希望每一组数据都有一行。为了让代码正常工作,我已经尝试了很多方法,但现在这正是我的困境。我正在使用[100110]测试数据,但当我运行代码时
IndexError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/utils/py3compat.py in execfile(fname, *where)
173 else:
174 filename = fname
--> 175 __builtin__.execfile(filename, *where)
/Users/Tyler/Desktop/Arduino/Graphing_22.py in <module>()
304 if __name__ == '__main__':
305 app = wx.PySimpleApp()
--> 306 app.frame = GraphFrame()
307 app.frame.Show()
308 app.MainLoop()
/Users/Tyler/Desktop/Arduino/Graphing_22.py in __init__(self)
87 self.create_menu()
88 self.create_status_bar()
---> 89 self.create_main_panel()
90
91 self.redraw_timer = wx.Timer(self)
/Users/Tyler/Desktop/Arduino/Graphing_22.py in create_main_panel(self)
109 self.panel = wx.Panel(self)
110
--> 111 self.init_plot()
112 self.canvas = FigCanvas(self.panel, -1, self.fig)
113
/Users/Tyler/Desktop/Arduino/Graphing_22.py in init_plot(self)
180 #adding a line to the plot
181 self.plot_data = self.axes.plot(
--> 182 self.data[1],
183 linewidth=1,
184 color=(1, 2, 0),
IndexError: list index out of range
代码真的很长,所以我会张贴我认为是相关的。如果还需要什么,请告诉我。谢谢你的帮助。在
^{pr2}$
错误消息
IndexError: list index out of range
表示行182
data[1]
超出范围-这意味着没有data[1]
元素(数据为len 1或len 0)。您需要在代码中找到构建data
列表的那一行,以理解为什么会出现这种情况。在相关问题 更多 >
编程相关推荐