• 技术文章 >Python技术 >Python基础教程

    python中pyg2plot如何使用?

    小妮浅浅小妮浅浅2021-02-26 18:01:53原创5033

    1、渲染出完整的 HTML

    这种情况可以用于:

    服务端 html 直出的场景

    生成可交互可视化分享

    Excel 等工具嵌入的场景

    from pyg2plot import Plot
     
    line = Plot("Line")
     
    line.set_options({
      "data": [
        { "year": "1991", "value": 3 },
        { "year": "1992", "value": 4 },
        { "year": "1993", "value": 3.5 },
        { "year": "1994", "value": 5 },
        { "year": "1995", "value": 4.9 },
        { "year": "1996", "value": 6 },
        { "year": "1997", "value": 7 },
        { "year": "1998", "value": 9 },
        { "year": "1999", "value": 13 },
      ],
      "xField": "year",
      "yField": "value",
    })
     
    # 1. render html file named plot.html
    line.render("plot.html")
     
    # 2. render html string
    line.render_html()

    2、在 Jupyter notebook 中预览

    from pyg2plot import Plot
     
    line = Plot("Line")
     
    line.set_options({
      "height": 400, # set a default height in jupyter preview
      "data": [
        { "year": "1991", "value": 3 },
        { "year": "1992", "value": 4 },
        { "year": "1993", "value": 3.5 },
        { "year": "1994", "value": 5 },
        { "year": "1995", "value": 4.9 },
        { "year": "1996", "value": 6 },
        { "year": "1997", "value": 7 },
        { "year": "1998", "value": 9 },
        { "year": "1999", "value": 13 },
      ],
      "xField": "year",
      "yField": "value",
    })
     
    line.render_notebook()

    在我们做数据分析教程的过程中,可以将我们的数据使用 PyG2Plot 进行可视化并预览出来,十分方便!

    以上就是python中pyg2plot的使用,希望能对大家有所帮助。更多Python学习指路:python基础教程

    专题推荐:python pyg2plot
    品易云
    上一篇:python线程优先级队列有哪些? 下一篇:python pyg2plot的原理

    相关文章推荐

    • python常量折叠是什么• python元组拆包如何实现?• python如何定义具名元组?• python线程优先级队列有哪些?

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网