当前位置: 首页>>代码示例>>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;未经允许,请勿转载。