采用matplotlib将数据描述成折线图
import matplotlib.pyplot as plt
import pandas as pd
ts = pd.Series(randn(10))
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ts.plot(ax=ax)
输入fig,可以看到图像:
接下来需要将fig存储为png格式,然后再用Image打开,再存储到excel表格中。
fig.savefig('foo.png')
writer = pd.ExcelWriter('savepicture.xlsx', engine='xlsxwriter')
sheet = writer.book.add_worksheet('test')
sheet.insert_image(0,0,'foo.png')
那么久可以在当前文件夹中看到savepicture.xlsx文件
打开excel表格,看到图片。