使用python生成简单的ppt图表
from pptx
import Presentation
from pptx
.chart
.data
import ChartData
from pptx
.enum
.chart
import XL_CHART_TYPE
from pptx
.util
import Inches
prs
= Presentation
()
slide
= prs
.slides
.add_slide
(prs
.slide_layouts
[5])
chart_data
= ChartData
()
chart_data
.categories
= ['East', 'West', 'Midwest']
chart_data
.add_series
('Series 1', (19.2, 21.4, 16.7))
x
, y
, cx
, cy
= Inches
(2), Inches
(2), Inches
(6), Inches
(4.5)
slide
.shapes
.add_chart
(
XL_CHART_TYPE
.COLUMN_CLUSTERED
, x
, y
, cx
, cy
, chart_data
)
prs
.save
(r
'c:/Users/Administrator/Desktop/cesgu.pptx')
转载请注明原文地址: https://mac.8miu.com/read-486292.html