涉及到时间序列的观察值,我们可以绘制折线图来做相关数据分析。例如:
1from pyecharts.charts import * 2from pyecharts import options as opts 3 4x_data = ['2-06', '2-13', '2-20', '2-27', '3-05', '3-12', '3-19', '3-26', '4-02', '4-09', '4-17'] 5# 现有确诊 6y1_data = [20677, 46537, 49156, 36829, 22695, 13171, 6287, 2896, 987, 351, 122] 7# 累计治愈 8y2_data = [817, 4131, 11788, 26403, 41966, 51533, 58381, 61731, 63612, 64236, 63494] 9line = (Line() 10 .add_xaxis(x_data) 11 .add_yaxis('现有确诊', y1_data, color='#10aeb5') 12 .add_yaxis('累计治愈', y2_data, color='#e83132') 13 .set_series_opts(label_opts=opts.LabelOpts(is_show=True)) 14 .set_global_opts( 15 title_opts=opts.TitleOpts(title='中国疫情随时间变化趋势') 16 )) 17 18# line.render(path='中国疫情折线图.html') 19line.render_notebook()
输出结果:

**文末小trips:**十六进制颜色码可参考: https://blog.csdn.net/bjbz_cxy/article/details/79514030