所以我想在条形图中添加一个值为 5 的参考线。像图片: 我的代码是这样的:
prs=Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[5])
chart_data = ChartData()
chart_data.categories = ['East', 'West', 'Midwest']
chart_data.add_series('Q1 Sales', (19.2, 21.4, 16.7))
chart_data.add_series('Q2 Sales', (22.3, 28.6, 15.2))
chart_data.add_series('Q3 Sales', (20.4, 26.3, 14.2))
x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
cchart = slide.shapes.add_chart(
XL_CHART_TYPE.COLUMN_CLUSTERED, x, y, cx, cy, chart_data
)
prs1=Presentation()
slide1 = prs1.slides.add_slide(prs1.slide_layouts[5])
chart_data1 = ChartData()
chart_data1.categories = ['East', 'West', 'Midwest']
chart_data1.add_series('Q1 Sales', (5, 5, 5))
chart_data1.add_series('Q2 Sales', (5, 5, 5))
chart_data1.add_series('Q3 Sales', (5, 5, 5))
lchart = slide1.shapes.add_chart(
XL_CHART_TYPE.LINE, x, y, cx, cy, chart_data1
)
chartc = cchart.chart
chartl = lchart.chart
a=chartl.plots._plotArea
b=chartc.plots._plotArea
k=a.getchildren()[0]
b.insert(0,k)
prs.save('testbarline.pptx')
问题是:当我打开演示文稿时,它显示“PowerPoint 发现 testbarline.pptx 中的内容存在问题”。然后我点击“修复”,它无法修复。这里有什么问题?谢谢!