The data providing the values displayed in a PowerPoint chart can be changed with python-pptx
using the Chart.replace_data()
method.
https://python-pptx.readthedocs.io/en/latest/api/chart.html#pptx.chart.chart.Chart.replace_data
A new ChartData
object is created to hold the new data, then that object is passed to the .replace_data()
method:
from pptx.chart.data import CategoryChartData
# ---define new chart data---
chart_data = CategoryChartData()
chart_data.categories = ['East', 'West', 'Midwest']
chart_data.add_series('Series 1', (19.2, 21.4, 16.7))
# ---replace chart data---
chart.replace_data(chart_data)
Note that this procedure is slightly different for an XY/Scatter chart or Bubble chart because those chart types use a different chart-data object.