PyEcharts 概述

第1关:快速上手

from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.render import make_snapshot

from snapshot_phantomjs import snapshot

def bar_chart() -> Bar:

    # ********* Begin *********#    
    bar = Bar()
    bar.add_xaxis(["Shirts", "Sweaters", "Ties", "Pants", "Windbreaker", "High-heels", "Socks"])
    bar.add_yaxis("Merchant-A", [114, 55, 27, 101, 125, 27, 105])
    bar.add_yaxis("Merchant-B", [57, 134, 137, 129, 145, 60, 49])
    bar.reversal_axis()
    bar.set_series_opts(label_opts=opts.LabelOpts(position="right"))
    bar.set_global_opts(title_opts=opts.TitleOpts(title="Bar-TestPicture"))
    # ********** End **********#
    return bar

make_snapshot(snapshot, bar_chart().render(), "StudentAnswer/student_answer.png")

预览大图

おすすめ

転載: blog.csdn.net/m0_54010885/article/details/121419810