pyecharts-快速入门

admin2024-10-03  10

pyecharts文档:渲染图表 - pyecharts - A Python Echarts Plotting Library built with love.

pyecharts-gallery文档:中文简介 - Document (pyecharts.org)

一、快速入门案例

from pyecharts.charts import Bar

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

bar=(
    Bar()
    .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
    .add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
)
bar.render("mypyecharts.html")

pyecharts-快速入门,第1张

from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.globals import ThemeType

# init_opts=opts.InitOpts(theme=ThemeType.DARK) 设置主题颜色
bar = Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK))
bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
bar.set_global_opts(title_opts=opts.TitleOpts(title="主标题",subtitle="副标题"))
bar.render()
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.globals import ThemeType

#pyecharts方法支持链式调用

bar=(
    Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK))
    .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
    .add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
    .set_global_opts(title_opts=opts.TitleOpts(title="主标题",subtitle="副标题"))
)
bar.render()

pyecharts-快速入门,第2张

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明原文出处。如若内容造成侵权/违法违规/事实不符,请联系SD编程学习网:675289112@qq.com进行投诉反馈,一经查实,立即删除!