无法使用MATPLOTLIB从EXCEL PLOT多个数据

我有一个1000行和300列的Excel文件。 我想绘制(第1列)vs(第2列到第288列); 我的第一列是我的X轴,其余的列在Y轴上。 我的代码在下面; 我没有显示。 没有错误信息。

from openpyxl import load_workbook import numpy as np import matplotlib.pyplot as plt wb = load_workbook('CombinedData1.xlsx') sheet_1 = wb.get_sheet_by_name('CombinedData') x = np.zeros(sheet_1.max_row) y = np.zeros(sheet_1.max_row) a = np.zeros(sheet_1.max_column) b = np.zeros(sheet_1.max_column) print (sheet_1.max_row) print (sheet_1.max_column) for i in range(0, sheet_1.max_row): for j in range(1, 7): x[i] = sheet_1.cell(row=i + 1, column=j).value y[j] = sheet_1.cell(row=i + 1, column=j).value # z[i] = sheet_1.cell(row=i + 1, column=3).value print x[i] # print y[i] plt.plot(x[i], y[i], 'bo-', label='Values') plt.grid(True) plt.xlim(0,100) plt.ylim(0,10) plt.show() 

我会考虑使用pandas

 import pandas df = pandas.read_excel('CombinedData1.xlsx', sheetname='CombinedData', header=None) df.plot(x=0) 

要么

 plt.plot(df[0], df[1]) 

尝试像下面的嵌套循环:

对于范围内的j(1,7):
      我在范围内(0,sheet_1.max_row):
                x [i] = sheet_1.cell(row = i + 1,column = j).value
                y [i] = sheet_1.cell(row = i + 1,column = j).value
                #z [i] = sheet_1.cell(row = i + 1,column = 3).value
                打印x [i]
                #print y [i]
       plt.plot(x,y,label ='值%d'%j,保持= 1)

暂停选项将把7个独立的地块组合成一个单一的地块。 此外,您应该考虑使用pandas包导入和处理表单数据。