python openpyxl包excel 绘制 线性图表

https://openpyxl.readthedocs.io/en/stable/charts/line.html

说明:来自英文手册未翻译

Line Charts

Line charts allow data to be plotted against a fixed axis. They are similar to scatter charts, the main difference is that with line charts each data series is plotted against the same values. Different kinds of axes can be used for the secondary axes.

Similar to bar charts there are three kinds of line charts: standard, stacked and percentStacked.

该部分代码如下(直到图片位置 结束):
from datetime import date

from openpyxl import Workbook
from openpyxl.chart import (
LineChart,
Reference,
)
from openpyxl.chart.axis import DateAxis

wb = Workbook()
ws = wb.active

rows = [
[‘Date’, ‘Batch 1’, ‘Batch 2’, ‘Batch 3’],
[date(2015,9, 1), 40, 30, 25],
[date(2015,9, 2), 40, 25, 30],
[date(2015,9, 3), 50, 30, 45],
[date(2015,9, 4), 30, 25, 40],
[date(2015,9, 5), 25, 35, 30],
[date(2015,9, 6), 20, 40, 35],
]

for row in rows:
ws.append(row)

c1 = LineChart()
c1.title = “Line Chart”

你可能感兴趣的:(python,仿真,excel,可视化,python)