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")
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()