zoukankan      html  css  js  c++  java
  • pyecharts的绘图原理详解

    引用:https://mp.weixin.qq.com/s/8vvtqxBXfw41GLjkcxSewg

    上官网,写示例

    https://pyecharts.org/#/zh-cn/quickstart

    from pyecharts.charts import Bar
    from pyecharts import options as opts
    # 内置主题类型可查看 pyecharts.globals.ThemeType
    from pyecharts.globals import ThemeType

    #渲染成图片文件
    from pyecharts.render import make_snapshot
    from snapshot_selenium import snapshot



    #单独调用方式
    # bar = Bar()
    # bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
    # bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
    # render 会生成本地 HTML 文件,默认会在当前目录生成 render.html 文件
    # 也可以传入路径参数,如 bar.render("mycharts.html")

    # V1 版本开始支持链式调用

    bar = (
    # Bar()
    # 使用主题
    Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT,width="1200px",height="600px"))
    .add_xaxis(["1衬衫", "2毛衣", "3领带", "4裤子", "5风衣", "6高跟鞋", "7袜子"])
    .add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105])
    .add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49])
    .add_yaxis("商家C", [57, 134, 137, 129, 145, 60, 49])
    # 标签位置,默认上面
    # .set_series_opts(label_opts=opts.LabelOpts(position="right"))
    .set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))
    # 或者直接使用字典参数
    # .set_global_opts(title_opts={"text": "主标题", "subtext": "副标题"}
    )
    # bar.render()

    #渲染成图片文件
    make_snapshot(snapshot,bar.render(),"bar.png")

    渲染成图片时报错:

     看了下,上述目录下的文件都有的,搜了下,有案例说是因为chrome某文件没有(chromedriver.exe),解决方案:

    一、查看 chrome版本

     二、按版本下载后放到python目录下:

    三、问题解决,生成图片。

  • 相关阅读:
    jsp实现登陆功能小实验
    netty
    shiro
    mybatis
    spring MVC
    spring
    集合框架面试题
    Redis面试题
    Dubbo面试题汇总
    阿里面试题
  • 原文地址:https://www.cnblogs.com/JercanYu/p/14375691.html
Copyright © 2011-2022 走看看