Reputation: 319
I am trying to see if we can increase the chart area of a line chart created using python-pptx
Referring to the below sample, I am trying to see how can I increase the width of the line chart
chart_data = ChartData()
chart_data.categories = ['Q1 Sales', 'Q2 Sales', 'Q3 Sales']
chart_data.add_series('West', (32.2, 28.4, 34.7))
chart_data.add_series('East', (24.3, 30.6, 20.2))
chart_data.add_series('Midwest', (20.4, 18.3, 26.2))
x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
chart = slide.shapes.add_chart(
XL_CHART_TYPE.LINE, x, y, cx, cy, chart_data
).chart
chart.has_legend = True
chart.legend.include_in_layout = False
chart.series[0].smooth = True
I have tried prs.slide_width = Mm(500) method but it increases all slides in the file.
I am trying to see if only a specific line chart width can be increased. Thanks
Upvotes: 0
Views: 412
Reputation: 29021
The cx
and cy
values in your example control the size of the final chart. Just make those bigger. You may also want to change the values of x
and y
as necessary to position the chart to your liking.
Upvotes: 1