Var*_*bar 4 python python-pptx
我想使用 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)
Run Code Online (Sandbox Code Playgroud)
根据图表/绘图类型的不同,存在一些微妙之处。请参阅此处的 API 文档以了解有关这些内容的更多信息。 https://python-pptx.readthedocs.io/en/latest/api/chart.html