[pyecharts]如何使用Python将多个图表生成到一个HTML中?

范例如下:

# coding:utf-8
from pyecharts.charts import Bar, Page
from pyecharts import options as opts
import os
if __name__ == '__main__':
    # pyecharts=1.8.1
    # 安装 python -m pip install pyecharts
    page = Page(layout=Page.DraggablePageLayout)
    bar = Bar()
    bar.add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
    bar.add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105])
    bar.add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49])
    bar.add_yaxis("商家C", [57, 134, 137, 129, 145, 60, 49])
    bar.set_global_opts(title_opts=opts.TitleOpts(title="某商场销售情况1"))
    bar1 = Bar()
    bar1.add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
    bar1.add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105])
    bar1.add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49])
    bar1.add_yaxis("商家C", [57, 134, 137, 129, 145, 60, 49])
    bar1.set_global_opts(title_opts=opts.TitleOpts(title="某商场销售情况2"))
    # 将柱状图bar和bar1添加到page页面中,这样就可以将两个图标绘制成一个html中了
    page.add(bar, bar1)
    page.render("test.html")
    os.system("test.html")

效果图如下:
《[pyecharts]如何使用Python将多个图表生成到一个HTML中?》

    原文作者:baosenzhang
    原文地址: https://blog.csdn.net/weixin_45329445/article/details/107963955
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞