【发布时间】:2014-05-12 10:25:43
【问题描述】:
我已经搜索过类似的问题,但找不到解决方案。在前面我对Python一无所知。我刚刚得到了一个理论上应该可以工作的脚本,并用一些点数据绘制了一个图表,但我收到了这个错误:
Traceback (most recent call last):
File "C:\***\create_plot.py", line 38, in <module>
formatter.create_plot()
File "C:\***\CPI_Plotter.py", line 54, in create_plot
plot(line[:, 0], line[:, 1], styles[name[0]%7], label=name[1])
IndexError: too many indices
相应的代码在这里:
def create_plot(self):
"""
Plot the different data sets
"""
styles = ['o', 's', '^', 'v', 'D', '1', '+']
for name, line in zip(enumerate(self.labels), self.plot_data):
if name[1][-4:] == '.csv':
plot(line[:, 0], line[:, 1], label='XNS Simulation')
styles.insert(name[0],'')
else:
plot(line[:, 0], line[:, 1], styles[name[0]%7], label=name[1])
感谢您的帮助!
【问题讨论】:
标签: python indexing runtime-error indices