数据替换前 数据替换后
代码实现
# 单折线
path='E:\\13 python 下侧双x轴折线图\\'
prs = Presentation(path+'双x轴测试-01.pptx')
data_time=pd.read_excel(path+"数据.xlsx",sheet_name='单折线')ppt_9=prs.slides[1].shapes
chart_data_9=CategoryChartData()
spendtime=data_time.iloc[0:29,0:3]
ser1=spendtime.iloc[0:,1]
ser2=spendtime.iloc[0:,2]
x=spendtime.iloc[0:32,0]
chart_data_9.categories=x
chart_data_9.add_series(name='系列一',values=ser1,number_format='0.0')
chart_data_9.add_series(name='系列二',values=ser2,number_format='0.0')
group_1=ppt_9[0]
chart_1=group_1
catrgory_axis_1=chart_1.chart.category_axis
catrgory_axis_1.tick_label_position=XL_TICK_LABEL_POSITION.LOW
catrgory_axis_1.tick_labels.font.size=Pt(12)
chart_1.chart.replace_data(chart_data=chart_data_9)prs.save(path+'line_chart0528.pptx')