python openpyxl包excel 绘制 线性图表

本文介绍了如何使用Python的openpyxl库创建线性图表,包括标准线图、堆叠线图和百分比堆叠线图,并提供了具体的代码示例。示例展示了如何设置数据系列、样式、轴标题以及日期轴。此外,还提到了3D线图的创建方法。
摘要由CSDN通过智能技术生成
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”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值