1.根据已有数据画图
import matplotlib.pyplot as plt
import numpy as np
import openpyxl as xl
f = xl.load_workbook('1.xlsx')
sheet = f['Sheet1']
cell = sheet.cell(1, 1)
print(cell.value)
list_x = []
list_y = []
for row in range(1, sheet.max_row + 1):
list_x.append(sheet.cell(row, 1).value)
list_y.append(sheet.cell(row, 2).value)
fig, ax = plt.subplots()
ax.plot(list_x, list_y, linewidth=2.0)
ax.set(xlim=(0, 2000), xticks=np.arange(1, 8),
ylim=(0, 150), yticks=np.arange(1, 8))
plt.show()