如何使用 Python PPTX 设置 DONUT 切片的颜色?
How do you set the color of a DOUGHNUT slice with Python PPTX?
我有一个包含两个切片的简单甜甜圈图。默认颜色为红色和蓝色。我想将颜色改为浅红色和浅绿色。
这会将两个切片都设置为绿色
#Doughnut
doughnutchart_data = ChartData()
doughnutchart_data.categories = ['incomplete','completed']
doughnutchart_data.add_series('YTD COMPLETION TO PLAN', (49.5,50.5))
# add chart to slide
x, y, cx, cy = Inches(6.6), Inches(0.8), Inches(4), Inches(3)
ThisDoughnutChart = ThisSlide.shapes.add_chart(
XL_CHART_TYPE.DOUGHNUT, x, y, cx, cy, doughnutchart_data
).chart
ThisDoughnutChart.has_legend = False
ThisDoughnutChart.series[0].format.fill.solid()
ThisDoughnutChart.series[0].format.fill.fore_color.rgb = RGBColor(13,230,2) # Green
尝试:
point = chart.series[0].points[0]
fill = point.format.fill
fill.solid()
fill.fore_color.rgb = RGBColor(13, 230, 2)
我有一个包含两个切片的简单甜甜圈图。默认颜色为红色和蓝色。我想将颜色改为浅红色和浅绿色。
这会将两个切片都设置为绿色
#Doughnut
doughnutchart_data = ChartData()
doughnutchart_data.categories = ['incomplete','completed']
doughnutchart_data.add_series('YTD COMPLETION TO PLAN', (49.5,50.5))
# add chart to slide
x, y, cx, cy = Inches(6.6), Inches(0.8), Inches(4), Inches(3)
ThisDoughnutChart = ThisSlide.shapes.add_chart(
XL_CHART_TYPE.DOUGHNUT, x, y, cx, cy, doughnutchart_data
).chart
ThisDoughnutChart.has_legend = False
ThisDoughnutChart.series[0].format.fill.solid()
ThisDoughnutChart.series[0].format.fill.fore_color.rgb = RGBColor(13,230,2) # Green
尝试:
point = chart.series[0].points[0]
fill = point.format.fill
fill.solid()
fill.fore_color.rgb = RGBColor(13, 230, 2)