当前位置: 首页>>代码示例>>Python>>正文


Python charts.Pie方法代码示例

本文整理汇总了Python中pyecharts.charts.Pie方法的典型用法代码示例。如果您正苦于以下问题:Python charts.Pie方法的具体用法?Python charts.Pie怎么用?Python charts.Pie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyecharts.charts的用法示例。


在下文中一共展示了charts.Pie方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: refer_pie_chart

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def refer_pie_chart() -> Pie:
    refer_hosts = list(filter(lambda x: x, R.smembers(settings.REDIS_REFER_ALL_KEY)))
    refer_host_pv_keys = [settings.REDIS_REFER_PV_KEY % host for host in refer_hosts]

    c = (
        Pie()
        .add(
            "",
            [list(z) for z in zip(refer_hosts, R.mget(*refer_host_pv_keys)) if int(z[1]) > 100],
            # radius=["30%", "75%"],
            # rosetype="radius",
        )
        .set_global_opts(
            title_opts=options.TitleOpts(title="Referer来源占比"),
            legend_opts=options.LegendOpts(
                type_="scroll", pos_left="80%", orient="vertical"
            ),
        )
        .set_series_opts(label_opts=options.LabelOpts(formatter="{b}: {c}"))
        .dump_options()
    )
    return c 
开发者ID:richshaw2015,项目名称:oh-my-rss,代码行数:24,代码来源:views_dash.py

示例2: sex_ratio

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def sex_ratio():

    # 初始化
    male, female, other = 0, 0, 0

    # 遍历
    for user in friends:
        if(user.sex == 1):
            male += 1
        elif(user.sex == 2):
            female += 1
        else:
            other += 1

    name_list = ['男性', '女性', '未设置']
    num_list = [male, female, other]

    pie = Pie()
    pie.add("微信好友性别比例", [list(z) for z in zip(name_list, num_list)])
    pie.set_global_opts(title_opts=opts.TitleOpts(title="微信好友性别比例"))
    pie.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    pie.render('data/好友性别比例.html')


# 分析好友地区分布 
开发者ID:shengqiangzhang,项目名称:examples-of-web-crawlers,代码行数:27,代码来源:generate_wx_data.py

示例3: main

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def main():
    with open('data/lyric_list.json') as f:
        data = json.load(f)

    # 停用词表来自:
    # https://github.com/XuJin1992/ChineseTextClassifier
    with open('data/stop_words.txt') as f:
        stop_words = f.read().split('\n')

    # 此处仅选择一首歌
    lyric = data[1]
    lyric = format_content(lyric)

    seg_list = word_segmentation(lyric, stop_words)

    counter = word_frequency(seg_list, 10)

    # plot_chart(counter, 'Pie')
    plot_chart(counter)
    
    # pprint(counter)
    # pprint(type(stop_words)) 
开发者ID:GreatV,项目名称:CloudMusic-Crawler,代码行数:24,代码来源:text_mining.py

示例4: v_positions

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def v_positions(self, date=yesterdayobj(), rendered=True):
        """
        pie chart visualization of positions ratio in combination
        """
        sdata = sorted(
            [
                (fob.name, fob.briefdailyreport(date).get("currentvalue", 0))
                for fob in self.fundtradeobj
            ],
            key=lambda x: x[1],
            reverse=True,
        )
        pie = Pie()
        pie.add(
            series_name="总值占比",
            data_pair=sdata,
            label_opts=opts.LabelOpts(is_show=False, position="center"),
        ).set_global_opts(
            legend_opts=opts.LegendOpts(
                pos_left="left", type_="scroll", orient="vertical"
            )
        ).set_series_opts(
            tooltip_opts=opts.TooltipOpts(
                trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)"
            ),
        )

        if rendered:
            return pie.render_notebook()
        else:
            return pie 
开发者ID:refraction-ray,项目名称:xalpha,代码行数:33,代码来源:multiple.py

示例5: statistics_friends

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def statistics_friends():
    # 初始化
    unknown, known_male, known_female, known_other = 0, 0, 0, 0

    # 遍历
    for user in friends:
        # 备注不为空
        if((user.remark_name).strip()):
            if(user.sex == 1):
                known_male += 1
            elif(user.sex == 2):
                known_female += 1
            else:
                known_other += 1
        else:
            unknown += 1

    name_list = ['未设置备注的好友', '设置备注的男性好友', '设置备注的女性好友', '设置备注的其他好友']
    num_list = [unknown, known_male, known_female, known_other]

    pie = Pie()
    pie.add("你认识的好友比例", [list(z) for z in zip(name_list, num_list)])
    pie.set_global_opts(title_opts=opts.TitleOpts(title="你认识的好友比例"))
    pie.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    pie.render('data/你认识的好友比例.html')


# 分析备注名称 
开发者ID:shengqiangzhang,项目名称:examples-of-web-crawlers,代码行数:30,代码来源:generate_wx_data.py

示例6: analyze_remark_name

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def analyze_remark_name():
    close_partner_dict = {'宝宝,猪,仙女,亲爱,老婆':0, '老公':0, '父亲,爸':0, '母亲,妈':0, '闺蜜,死党,基友':0}

    # 遍历好友数据
    for user in friends:
        for key in close_partner_dict.keys():
            # 判断该好友备注名是否包含close_partner_dict中的任意一个key
            name = key.split(',')
            for sub_name in name:
                if(sub_name in user.remark_name):
                    close_partner_dict[key] += 1
                    break


    name_list = ['最重要的她', '最重要的他', '爸爸', '妈妈', '死党']
    num_list = [x for x in close_partner_dict.values()]

    pie = Pie()
    pie.add("可能是你最亲密的人", [list(z) for z in zip(name_list, num_list)])
    pie.set_global_opts(title_opts=opts.TitleOpts(title="可能是你最亲密的人"))
    pie.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    pie.render('data/你最亲密的人.html')



# 分析个性签名 
开发者ID:shengqiangzhang,项目名称:examples-of-web-crawlers,代码行数:28,代码来源:generate_wx_data.py

示例7: plot_chart

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def plot_chart(counter, chart_type='Bar'):

    items = [item[0] for item in counter]
    values = [item[1] for item in counter]

    if chart_type == 'Bar':
        # chart = Bar('词频统计')
        # chart.add('词频', items, values, is_more_utils=True)
        chart = (
            Bar()
            .add_xaxis(items)
            .add_yaxis('词频', values)
            .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
            .set_global_opts(title_opts=opts.TitleOpts(title='词频统计'))
            )
    else:
        # chart = Pie('词频统计')
        # chart.add('词频', items, values, is_label_show=True, is_more_utils=True)
        chart = (
            Pie()
            .add_xaxis(items)
            .add_yaxis('词频', values)
            .set_series_opts(label_opts=opts.LabelOpts(is_show=True))
            .set_global_opts(title_opts=opts.TitleOpts(title='词频统计'))
            )
    
    chart.render() 
开发者ID:GreatV,项目名称:CloudMusic-Crawler,代码行数:29,代码来源:text_mining.py

示例8: drawPie

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def drawPie(title, data, savepath='./results'):
	checkDir(savepath)
	pie = (Pie(init_opts=options.InitOpts(theme=ThemeType.VINTAGE))
		  .add('', [list(item) for item in data.items()], radius=['30%', '75%'], center=['50%', '50%'], rosetype='radius')
		  .set_global_opts(title_opts=options.TitleOpts(title=title, pos_left='center'), legend_opts=options.LegendOpts(orient='vertical', pos_top='5%', pos_left='2%')))
	pie.render(os.path.join(savepath, title+'.html')) 
开发者ID:CharlesPikachu,项目名称:DecryptLogin,代码行数:8,代码来源:analysis.py

示例9: drawPie

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def drawPie(title, data, savedir='./results'):
    checkDir(savedir)
    pie = (Pie(init_opts=options.InitOpts(theme=ThemeType.VINTAGE))
          .add('', [list(item) for item in data.items()], radius=['30%', '75%'], center=['50%', '50%'], rosetype='radius')
          .set_global_opts(title_opts=options.TitleOpts(title=title, pos_left='center'), legend_opts=options.LegendOpts(orient='vertical', pos_top='5%', pos_left='2%')))
    pie.render(os.path.join(savedir, title+'.html')) 
开发者ID:CharlesPikachu,项目名称:DecryptLogin,代码行数:8,代码来源:analysis.py

示例10: v_category_positions

# 需要导入模块: from pyecharts import charts [as 别名]
# 或者: from pyecharts.charts import Pie [as 别名]
def v_category_positions(self, date=yesterdayobj(), rendered=True):
        """
        资产分类扇形图,按大类资产求和绘制

        :param date:
        :param rendered: bool. default true for notebook, for plain pyechart obj to return, set rendered=False
        :return:
        """
        d = {}
        for f in self.fundtradeobj:
            if isinstance(f, itrade):
                t = f.get_type()
                if t == "场内基金":
                    t = get_fund_type(f.code[2:])
            elif f.code == "mf":
                t = "货币基金"
            else:
                t = get_fund_type(f.code)
            if t == "其他":
                logger.warning(
                    "%s has category others which should be double checked" % f.code
                )
            d[t] = d.get(t, 0) + f.briefdailyreport(date).get("currentvalue", 0)

        sdata = sorted([(k, round(v, 2)) for k, v in d.items()])
        pie = Pie()
        pie.add(
            series_name="总值占比",
            data_pair=sdata,
            label_opts=opts.LabelOpts(is_show=False, position="center"),
        ).set_global_opts(
            legend_opts=opts.LegendOpts(
                pos_left="left", type_="scroll", orient="vertical"
            )
        ).set_series_opts(
            tooltip_opts=opts.TooltipOpts(
                trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)"
            ),
        )

        if rendered:
            return pie.render_notebook()
        else:
            return pie 
开发者ID:refraction-ray,项目名称:xalpha,代码行数:46,代码来源:multiple.py


注:本文中的pyecharts.charts.Pie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。