當前位置: 首頁>>代碼示例>>Python>>正文


Python charts.Bar方法代碼示例

本文整理匯總了Python中pyecharts.charts.Bar方法的典型用法代碼示例。如果您正苦於以下問題:Python charts.Bar方法的具體用法?Python charts.Bar怎麽用?Python charts.Bar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyecharts.charts的用法示例。


在下文中一共展示了charts.Bar方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _draw_bar

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def _draw_bar(result: ClassifierResult) -> Bar:
        # draw bar chart
        bar = Bar(init_opts=opts.InitOpts(bg_color=constants.BACKGROUND_COLOR))
        x_axis = sorted(list(result.get_stage_set()))
        y_axis = list()
        offset = result.get_offset()
        for each_stage_name in x_axis:
            ranges = result.get_specific_stage_range(each_stage_name)
            time_cost: float = 0.0
            for each in ranges:
                # last frame - first frame
                time_cost += each[-1].timestamp - each[0].timestamp + offset
            y_axis.append(time_cost)

        bar.add_xaxis(x_axis)
        bar.add_yaxis("time cost", y_axis)
        bar.set_global_opts(
            title_opts=opts.TitleOpts(title="Time Cost", subtitle="... of each stages"),
            toolbox_opts=opts.ToolboxOpts(is_show=True),
        )
        logger.debug(f"time cost: {dict(zip(x_axis, y_axis))}")
        return bar 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:24,代碼來源:reporter.py

示例2: draw_image

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def draw_image(self):
        """
        畫圖
        :return:
        """
        usernames = []
        counts = []
        for user in self.top_data:
            # 去除昵稱中的特殊符號
            usernames.append(get_ava_string(user.get('username').strip())[0:8])
            counts.append(user.get('count'))

        def bar_chart() -> Bar:
            c = (
                Bar()
                    .add_xaxis(usernames)
                    .add_yaxis("活躍度", counts)
                    .reversal_axis()
                    .set_series_opts(label_opts=opts.LabelOpts(position="right"))
                    .set_global_opts(title_opts=opts.TitleOpts(title="最活躍的%d個小夥伴" % self.top_num))
            )
            return c

        # 需要安裝 snapshot-selenium 或者 snapshot-phantomjs
        make_snapshot(driver, bar_chart().render(), "bar.png") 
開發者ID:xingag,項目名稱:spider_python,代碼行數:27,代碼來源:main.py

示例3: analyze_special_friends

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def analyze_special_friends():

    # 星標好友(很重要的人), 不讓他看我的朋友圈的好友, 不看他朋友圈的好友, 消息置頂好友, 陌生人
    star_friends, hide_my_post_friends, hide_his_post_friends, sticky_on_top_friends, stranger_friends = 0, 0, 0, 0, 0

    for user in friends:


        # 星標好友為1,為0表示非星標,不存在星標選項的為陌生人
        if('StarFriend' in (user.raw).keys()):
            if((user.raw)['StarFriend'] == 1):
                star_friends += 1
        else:
            stranger_friends += 1

        # 好友類型及權限:1和3好友,259和33027不讓他看我的朋友圈,65539和65537和66051不看他的朋友圈,65795兩項設置全禁止, 73731陌生人
        if((user.raw)['ContactFlag'] in [259, 33027, 65795]):
            hide_my_post_friends += 1
        if ((user.raw)['ContactFlag'] in [66051, 65537, 65539, 65795]):
            hide_his_post_friends += 1

        # 消息置頂好友為2051
        if ((user.raw)['ContactFlag'] in [2051]):
            sticky_on_top_friends += 1

        # 陌生人
        if ((user.raw)['ContactFlag'] in [73731]):
            stranger_friends += 1


    bar = Bar()
    bar.add_xaxis(['星標', '不讓他看我朋友圈', '不看他朋友圈', '消息置頂', '陌生人'])
    bar.add_yaxis('特殊好友分析', [star_friends, hide_my_post_friends, hide_his_post_friends, sticky_on_top_friends, stranger_friends])
    bar.render('data/特殊好友分析.html')



# 共同所在群聊成員分析 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:40,代碼來源:generate_wx_data.py

示例4: plot_chart

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [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

示例5: show_bar_image

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def show_bar_image():
    bar = Bar()
    bar.add_xaxis(["Readmi Note7", "小米9", "小米MIX 3", "小米9SE"])
    bar.add_yaxis("小米", [2000, 900, 300, 500])
    bar.render("bar.html") 
開發者ID:menhuan,項目名稱:notes,代碼行數:7,代碼來源:echarts_display.py

示例6: show_salary_bar

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def show_salary_bar(count):
    bar = (
        Bar()
            .add_xaxis(list(count.index))
            .add_yaxis("人數", count.tolist())

    )
    bar.render("month_salary.html") 
開發者ID:menhuan,項目名稱:notes,代碼行數:10,代碼來源:echarts_display.py

示例7: drawBar

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def drawBar(title, data, savepath='./results'):
	checkDir(savepath)
	bar = (Bar(init_opts=options.InitOpts(theme=ThemeType.VINTAGE))
		  .add_xaxis(list(data.keys()))
		  .add_yaxis('', list(data.values()))
		  .set_global_opts(xaxis_opts=options.AxisOpts(axislabel_opts=options.LabelOpts(rotate=-30)),
		  				   title_opts=options.TitleOpts(title=title, pos_left='center'), legend_opts=options.LegendOpts(orient='vertical', pos_top='15%', pos_left='2%')))
	bar.render(os.path.join(savepath, title+'.html')) 
開發者ID:CharlesPikachu,項目名稱:DecryptLogin,代碼行數:10,代碼來源:analysis.py

示例8: drawBar

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def drawBar(title, data, savedir='./results'):
    checkDir(savedir)
    bar = (Bar(init_opts=options.InitOpts(theme=ThemeType.VINTAGE))
          .add_xaxis(list(data.keys()))
          .add_yaxis('', list(data.values()))
          .set_global_opts(xaxis_opts=options.AxisOpts(axislabel_opts=options.LabelOpts(rotate=-15)),
                           title_opts=options.TitleOpts(title=title, pos_left='center'), legend_opts=options.LegendOpts(orient='vertical', pos_top='15%', pos_left='2%')))
    bar.render(os.path.join(savedir, title+'.html')) 
開發者ID:CharlesPikachu,項目名稱:DecryptLogin,代碼行數:10,代碼來源:analysis.py

示例9: drawBar

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def drawBar(title, data, savedir='./results'):
    checkDir(savedir)
    bar = (Bar(init_opts=options.InitOpts(theme=ThemeType.VINTAGE))
          .add_xaxis(list(data.keys()))
          .add_yaxis('', list(data.values()))
          .set_global_opts(xaxis_opts=options.AxisOpts(axislabel_opts=options.LabelOpts(rotate=-25)),
                           title_opts=options.TitleOpts(title=title, pos_left='center'), legend_opts=options.LegendOpts(orient='vertical', pos_top='15%', pos_left='2%')))
    bar.render(os.path.join(savedir, title+'.html')) 
開發者ID:CharlesPikachu,項目名稱:DecryptLogin,代碼行數:10,代碼來源:analysis.py

示例10: region_distribution

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def region_distribution():

    # 使用一個字典統計好友地區分布數量
    province_dict = {'北京': 0, '上海': 0, '天津': 0, '重慶': 0,
                     '河北': 0, '山西': 0, '吉林': 0, '遼寧': 0, '黑龍江': 0,
                     '陝西': 0, '甘肅': 0, '青海': 0, '山東': 0, '福建': 0,
                     '浙江': 0, '台灣': 0, '河南': 0, '湖北': 0, '湖南': 0,
                     '江西': 0, '江蘇': 0, '安徽': 0, '廣東': 0, '海南': 0,
                     '四川': 0, '貴州': 0, '雲南': 0, '內蒙古': 0, '新疆': 0,
                     '寧夏': 0, '廣西': 0, '西藏': 0, '香港': 0, '澳門': 0}

    # 遍曆
    for user in friends:
        # 判斷省份是否存在,有可能是外國的,這種情況不考慮
        if (user.province in province_dict):
            key = user.province
            province_dict[key] += 1

    province = list(province_dict.keys())
    values = list(province_dict.values())


    # maptype='china' 隻顯示全國直轄市和省級,數據隻能是省名和直轄市的名稱
    map = Map()
    map.add("微信好友地區分布", [list(z) for z in zip(province, values)], "china")
    map.set_global_opts(
            title_opts=opts.TitleOpts(title="微信好友地區分布"),
            visualmap_opts=opts.VisualMapOpts(),
        )
    map.render(path="data/好友地區分布.html")



    # 對好友數最多的省份進行一進步分析
    max_count_province = ''
    for key, value in province_dict.items():
        if(value == max(province_dict.values())):
            max_count_province = key
            break

    # 使用一個字典統計好友地區分布數量
    city_dict = {}
    # 遍曆
    for user in friends:
        if(user.province == max_count_province):
            # 更新鍵值對
            if(user.city in city_dict.keys()):
                city_dict[user.city] += 1
            else:
                city_dict[user.city] = 1

    bar = Bar()
    bar.add_xaxis([x for x in city_dict.keys()])
    bar.add_yaxis("地區分布", [x for x in city_dict.values()])
    bar.render('data/某省好友地區分布.html')


# 統計認識的好友的比例 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:60,代碼來源:generate_wx_data.py

示例11: group_common_in

# 需要導入模塊: from pyecharts import charts [as 別名]
# 或者: from pyecharts.charts import Bar [as 別名]
def group_common_in():

    # 獲取所有活躍的群聊
    groups = bot.groups()

    # 每個好友與你相同的群聊個數
    dict_common_in = {}

    # 遍曆所有好友,第0個為你自己,所以去掉
    for x in friends[1:]:
        # 依次在每個群聊中搜索
        for y in groups:
            # x在y中
            if(x in y):
                # 獲取微信名稱
                name = x.nick_name
                # 判斷是否有備注,有的話就使用備注
                if(x.remark_name and x.remark_name != ''):
                    name = x.remark_name

                # 增加計數
                if(name in dict_common_in.keys()):
                    dict_common_in[name] += 1
                else:
                    dict_common_in[name] = 1

    # 從dict_common_in結果中取出前n大個數據
    n = 0

    if(len(dict_common_in) > 5):
        n = 6
    elif(len(dict_common_in) > 4):
        n = 5
    elif(len(dict_common_in) > 3):
        n = 4
    elif(len(dict_common_in) > 2):
        n = 3
    elif(len(dict_common_in) > 1):
        n = 2
    elif(len(dict_common_in) > 0):
        n = 1

    # 排序,並轉化為list
    sort_list = sorted(dict_common_in.items(), key=lambda item: item[1], reverse=True)

    # 取出前n大的值
    sort_list = sort_list[:n]

    bar = Bar()
    bar.add_xaxis([x[0] for x in sort_list])
    bar.add_yaxis("共同所在群聊分析", [x[1] for x in sort_list])
    bar.render('data/共同所在群聊分析.html')


# 運行前,請先確保安裝了所需庫文件
# 若沒安裝,請執行以下命令:pip install -r requirement.txt 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:58,代碼來源:generate_wx_data.py


注:本文中的pyecharts.charts.Bar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。