python excel画图

利用xlwings画图

import os
import pandas as pd
import numpy as np
import xlwings as xw


#     Pn =   float(i[:-1])*1000  #从文件夹名字提取额定功率
#     In =   Pn/3/220
data = pd.read_csv('17K 30P.csv', header = 100) 
data.to_excel('aaa.xlsx')
# store = pd.DataFrame(data,columns = ['PF-E1','PF-E2','PF-E3'] )


app = xw.App(visible = False)
# workbook = app.books.add()

workbook = app.books.open('aaa.xlsx')
worksheet = workbook.sheets['Sheet1'] 

chart = worksheet.charts.add(left = 200, top = 0, width = 355, height= 211) # 设置图表的位置和尺寸
chart.set_source_data(worksheet['A1'].expand()) # 读取工作表中要制作图表的数据
chart.chart_type = 'xy_scatter_lines_no_markers' # 制作柱形图
workbook.save('柱形图.xlsx') # 另存工作簿


workbook.close()
app.quit()
# print(data)
print("completed")

python excel画图_第1张图片

你可能感兴趣的