问题描述
由于存在不同的问题,我将基于此提出一个新问题:
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 (将#修改为@)