replace_data in python pptx seems to replace the data from the excel sheet of the chart data, which can be found when we right click on any chart and click on edit data. But the changes do not reflect on the data labels associated with the chart in the ppt. Can anyone help me how to update this ppt data labels? Look at the chart image below:
https://i.stack.imgur.com/xdJoB.jpg
Code:
chart_data = CategoryChartData()
for i in range(1):
#i=1
data = df[:5] # 5 values to insert at once
data= data.iloc[::-1].reset_index(drop= True)
chart_data.categories = data['Unnamed: 0'].tolist()
chart_data.add_series(series_name, tuple(data['Unnamed: 2']))
chart = shapes_by_id[chart_idx].chart # chart_idx is the chart index
# since there are more than one chart in one slide
chart.replace_data(chart_data)
df.drop(df[:5].index,inplace = True)
df.reset_index(drop =True,inplace=True)
Below is the dataframe image: