當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。