要绘制连线的折线图,需要在添加数据系列时指定折线的类型。修改代码如下:

def get_gdp_line(datas_heu):
    # 下面开始绘制折线图
    line_chart = Line()
    for i in range(2003, 2023):
        year_data = datas_heu[['地区', str(i) + '年']].copy()

        line_chart.add_xaxis(year_data['地区'].tolist())  # x轴数据为地区列表

        line_chart.add_yaxis('{}'.format(i), year_data[str(i) + '年'].tolist(), is_connect_nones=True)  # 添加折线数据,并设置is_connect_nones参数为True

    line_chart.render('2022年全国各省GDP_line.html')

get_gdp_line(datas_heu)

这样修改后,折线图将会绘制连线。

Python Echarts 折线图绘制:连接数据点,绘制全国各省 GDP 趋势

原文地址: https://www.cveoy.top/t/topic/crKl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录