gpt4 book ai didi

python - 使用 python-pptx 从现有图表中读取图表数据

转载 作者:行者123 更新时间:2023-12-04 11:00:41 26 4
gpt4 key购买 nike

我想使用 python-pptx 库从演示文稿中的图表中读取数据。我看过替换图表数据的文档,但我不知道如何读取数据。

最佳答案

图表数据为:

  • 图表的图表类型
  • 它的类别名称(以及可能的层次结构)
  • 其系列名称
  • 及其系列值

这些在绘图级别可用,例如:

>>> chart.chart_type
DOUGHNUT
>>> plot = chart.plots[0]
>>> category_labels = [c.label for c in plot.categories]
["West", "North", "South"]
>>> series = plot.series[0]
>>> series.name
'Sales'
>>> series.values
(17.8, 24.5, 88.0)

根据图表/绘图类型,存在细微差别。在此处查阅 API 文档以了解更多信息。 https://python-pptx.readthedocs.io/en/latest/api/chart.html

关于python - 使用 python-pptx 从现有图表中读取图表数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58818347/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com