如何解决如何使用python-pptx模块在Power Point中绘制带有标签和标题的折线图中的添加垂直线?
由于存在不同的问题,我将基于此提出一个新问题:
How to plot particular line chart with labels and titles in power point using python-pptx module?
A B C D
AR 20201 1 200
AR 20202 1 300
AR 20203 1 1000
AR 20204 1 3000
AR 20205 1 700
AR 20206 1 800
AR 20207 1 900
AR 20201 2 1000
AR 20202 2 2000
AR 20203 2 3000
AR 20204 2 4000
AR 20205 2 5676
AR 20206 2 6000
AR 20207 2 1000
AR 20201 3 4500
AR 20202 3 4567
AR 20203 3 1000
AR 20204 3 900
AR 20205 3 600
AR 20206 3 200
AR 20207 3 100
==========================
BR 20201 1
BR 20202 1
BR 20203 1
BR 20204 1
BR 20205 1
BR 20206 1
BR 20207 1
BR 20201 2
-- ---- ---
我正在使用循环在ppt中创建多重折线图。对于国家/地区(A列)= AR,我正在同一图上绘制不同C = 1,2和3的折线图。在Y轴上,我将有D列,在X轴上,我将有B列
chart_data = ChartData()
cat=['202001','202002','202003','202004','202005','202006','202007']
chart_data.categories = cat
for i in list(data["C"].unique()):
chart_data.add_series(i,tuple(data[data['C']==i]['D']))
x,y,cx,cy = Inches(1),Inches(1),Inches(10.5),Inches(6)
chart = slide.shapes.add_chart(XL_CHART_TYPE.LINE,x,cy,chart_data).chart
chart.has_legend = True
chart.legend.include_in_layout = False
chart.series[0].smooth = True
这是我得到的输出:
预期输出为
How can I add a dotted vertical line,move the legend to the top and change font size of legend,and finally to add xlabel,ylabel and titles using the above code?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。