利用 Pyecharts 制作饼图

利用 Pyecharts 制作饼图:

from pyecharts import options as opts
from pyecharts.charts import Pie
from random import randint

def pie_base() -> Pie:
    c = (
        Pie()
        .add("", [list(z) for z in zip(['宝马','法拉利','奔驰','奥迪','大众','丰田','特斯拉'],
                                       [randint(1, 20) for _ in range(7)])])
        .set_global_opts(title_opts=opts.TitleOpts(title="Pie-基本示例"))
        .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    )
    return c

pie_base().render('G:/PythonWorkSpace/MatplotlibNumpyPandas/pie_pyecharts.html')

在这里插入图片描述

发布了49 篇原创文章 · 获赞 76 · 访问量 2699

猜你喜欢

转载自blog.csdn.net/qq_39783601/article/details/104665594