获取主机内存已使用(列表mem_used)和总内存(列表mem_total)数据后,通过xlsxwriter模块创建了一个excel文件,然后使用xlsxwriter绘制内存占用折线图,折线图需要两根线,一根是mem_used的变化折线,还有一根是mem_total每个元素一半的变化折线。mem_total每个元素的一半我生成了一个列表mem_total_half,现在怎么把mem_total_half这个列表的数据插入到折线图中(mem_total_half的数据不能才excel中体现)?
#插入mem_used
chart_col.add_series({
'name': '=sheet1!$C$1',
'values': '=sheet1!$C$2:$C$101',
'line': {'color': 'blue'},
})
#插入mem_total/2
chart_col.add_series({
'name': '=sheet1!$B$1',
'values': '=sheet1!' + mem_total_half[0] + ':' + mem_total_half[99], #想在这里插入一条线,数据来自mem_total_half这个列表,但是我这里的写法是错误的,代码运行不能通过
'line': {'color': 'yellow'},
})
chart_col.set_title({'name': 'mem资源占用'})
worksheet.insert_chart('G16', chart_col, {'x_scale': 1, 'y_scale': 1})
https://blog.csdn.net/sinat_35930259/article/details/78131684
查了下xlsxwriter官网https://xlsxwriter.readthedocs.io/contents.html
,貌似add_chart()没有可以在绘图时采用当前创建的excel以外数据的方法?