from pyecharts.charts import Bar from pyecharts import options as opts from pyecharts.globals import ThemeType bar = Bar(init_opts=opts.InitOpts(theme="essos",renderer="RenderType.SVG"))#render设置渲染格式 bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) # render 会生成本地 HTML 文件,默认会在当前目录生成 render.html 文件 # 也可以传入路径参数,如 bar.render("mycharts.html") bar.set_global_opts(title_opts=opts.TitleOpts(subtitle="图片"), datazoom_opts=opts.DataZoomOpts(is_show=True), yaxis_opts=opts.AxisOpts(max_=100), toolbox_opts=opts.ToolboxOpts(is_show=True))#全局修饰 bar.set_series_opts(label_opts=opts.LabelOpts(font_style="italic",font_size=20),#设置标签斜体,设置标签大小 markpoint_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="max",name="最大值"),#设置标线,设置标线名字 opts.MarkLineItem(type_="min",name="最小值"), opts.MarkLineItem(type_="average",name="平均值")])) bar.render()