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


Python charts.Bar方法代码示例

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


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

示例1: make_overview_bokeh

# 需要导入模块: from bokeh import charts [as 别名]
# 或者: from bokeh.charts import Bar [as 别名]
def make_overview_bokeh(data):
    if data:
        temps = "".join(data)
        values = re.findall(r'(\d+)', temps)
        c_values = [int(value) for value in values]
        c_keys = re.findall('[\u4e00-\u9fa5]+', temps)
        s = pd.Series(c_values, index=c_keys)
        data = s
        # ?????????????????????
        p = Bar(data,title="???", ylabel='?????', width=400, height=400,legend=None,tools="")
        script, div = components(p, CDN)

        return [script, div]
    else:
        return [0,file_hepler.get_image_path("no_overview.png")] 
开发者ID:Jasonhy,项目名称:ProductAnalysis,代码行数:17,代码来源:make_bokeh_hepler.py

示例2: get_counties_plot

# 需要导入模块: from bokeh import charts [as 别名]
# 或者: from bokeh.charts import Bar [as 别名]
def get_counties_plot(data_frame):
    plot = Bar(data_frame, label='CTYNAME', values='TOT_POP', agg='max', plot_width=1200, plot_height=500,
               title='Population by County', legend=False)
    plot.xaxis.axis_label = 'County'
    plot.yaxis.axis_label = 'Population'
    plot.yaxis.formatter = NumeralTickFormatter(format="0a")
    plot.sizing_mode = 'scale_width'
    return plot 
开发者ID:abarto,项目名称:pandas-drf-tools-test,代码行数:10,代码来源:views.py

示例3: make_bar

# 需要导入模块: from bokeh import charts [as 别名]
# 或者: from bokeh.charts import Bar [as 别名]
def make_bar():
    job_val = job.value
    x_name = axis_map[x_axis.value]
    get_level_sql = 'select %s,count(*) as count from lagou_data_job where job_name="%s" group by %s order by count desc limit 0,15'%(x_name, job_val, x_name)
    if(job_val == 'All'):
        get_level_sql = 'select %s,count(*) as count from lagou_data_job group by %s order by count desc limit 0,15'%(x_name, x_name)

    options = pd.read_sql(get_level_sql, con=mysql_cn)
    x_options = options[x_name].values.tolist()
    data = {}
    if(x_name == 'aver_salary'):
        salary = []
        for i in [1,3,5,10]:
            year_by_salary_sql = 'select avg(aver_salary) from lagou_data_job where job_name = "%s" and years = "%d"'%(job_val, i)
            if(job_val == 'All'):
                year_by_salary_sql = 'select avg(aver_salary) from lagou_data_job where years = "%d"'%(i)
            df = pd.read_sql(year_by_salary_sql, con=mysql_cn)
            sal_init = df['avg(aver_salary)'].values.tolist()[0]
            sal = math.ceil(sal_init) if sal_init != None else 0
            salary.append(sal)    
        data['count'] = salary
        data[x_name] = [u'1-3?', u'3-5?', u'5-10?', u'10???']
    elif(x_name == 'fields'):
        field_count = []
        for field in field_list:
            get_field_sql = "select fields, count(*) as count from lagou_data_job where fields like '%"+ field +"%' and job_name = '%s' group by fields"%(job_val)
            field_option = pd.read_sql(get_field_sql, con=mysql_cn)
            field_value = sum(field_option['count'].values.tolist())
            field_count.append(field_value)
        data[x_name] = field_list
        data['count'] = field_count
    else:
        y_values = options['count'].values.tolist()
        data = {}
        data[x_name] = x_options
        data['count'] = y_values
    p = Bar(data, values='count', label=x_name, agg='mean',
          title=u"?%s????"%(x_axis.value), legend='top_right', width=600)
    p.xaxis.axis_label = x_axis.value
    p.yaxis.axis_label = u'??'
    return p 
开发者ID:jasminecjc,项目名称:lagou_data_analysis,代码行数:43,代码来源:lagou_data_job.py

示例4: make_bar

# 需要导入模块: from bokeh import charts [as 别名]
# 或者: from bokeh.charts import Bar [as 别名]
def make_bar(counter, keywords, output_filename):
    data = pd.Series(filter_counter(counter, keywords))
    bar = Bar(data, title='Word Counts')
    output_file(output_filename)
    bar.show() 
开发者ID:kronosapiens,项目名称:twitter-research,代码行数:7,代码来源:wordcount_visualizer.py

示例5: make_bar

# 需要导入模块: from bokeh import charts [as 别名]
# 或者: from bokeh.charts import Bar [as 别名]
def make_bar():
    lan_val = lan.value
    x_name = axis_map[x_axis.value]
    get_level_sql = 'select %s,count(*) as count from lagou_lan where lan="%s" group by %s order by count desc limit 0,15'%(x_name, lan_val, x_name)
    if(lan_val == 'All'):
        get_level_sql = 'select %s,count(*) as count from lagou_lan group by %s order by count desc limit 0,15'%(x_name, x_name)

    options = pd.read_sql(get_level_sql, con=mysql_cn)
    x_options = options[x_name].values.tolist()
    data = {}
    #???????
    if(x_name == 'aver_salary'):
        salary = []
        for i in [1,3,5,10]:
            year_by_salary_sql = 'select avg(aver_salary) from lagou_lan where lan = "%s" and years = "%d"'%(lan_val, i)
            if(lan_val == 'All'):
                year_by_salary_sql = 'select avg(aver_salary) from lagou_lan where years = "%d"'%(i)
            df = pd.read_sql(year_by_salary_sql, con=mysql_cn)
            sal_init = df['avg(aver_salary)'].values.tolist()[0]
            sal = math.ceil(sal_init) if sal_init != None else 0
            salary.append(sal)    
        data['count'] = salary
        data[x_name] = [u'1-3?', u'3-5?', u'5-10?', u'10???']
    elif(x_name == 'fields'):
        field_count = []
        for field in field_list:
            get_field_sql = "select fields, count(*) as count from lagou_lan where fields like '%"+ field +"%' and lan = '%s' group by fields"%(lan_val)
            field_option = pd.read_sql(get_field_sql, con=mysql_cn)
            field_value = sum(field_option['count'].values.tolist())
            field_count.append(field_value)
        data[x_name] = field_list
        data['count'] = field_count
    else:
        y_values = options['count'].values.tolist()
        data = {}
        data[x_name] = x_options
        data['count'] = y_values
    p = Bar(data, values='count', label=x_name, agg='mean',
          title=u"?%s????"%(x_axis.value), legend='top_right', width=600)
    p.xaxis.axis_label = x_axis.value
    p.yaxis.axis_label = u'??'
    return p 
开发者ID:jasminecjc,项目名称:lagou_data_analysis,代码行数:44,代码来源:lagou_lan.py

示例6: participation_plot

# 需要导入模块: from bokeh import charts [as 别名]
# 或者: from bokeh.charts import Bar [as 别名]
def participation_plot(df_stitched_all, labels, member=None, member_names=None):
    """
    Creates simple participation chart (no percentages in hover, Tabs with speaking turns, speaking time
    :param df_stitched_all: a list of lists of df_stitched
    :param labels: a list of dates/weeks for which the df_stitched lists are for (excluding 'Average')
    :param member: Member who is viewing the report (serves as base of bar stacks). Either..
    - member key if no member_names dictionary is given, or
    - member name if member_names dictionary is given
    :param member_names: A dictionary mapping member keys to member names (First Last format)
    :return: bokeh plot
    """
    participation_values = percentage_participation(df_stitched_all, labels, member_names=member_names)
    if isinstance(participation_values, basestring):
        participation_values = ast.literal_eval(participation_values)
    if participation_values is None:
        print('ERROR: No participation values found')
        return (None, None)
    # Turn participation_values into format needed for bokeh's stacked Bar Chart
    data_dict = {'labels': [], 'member': [], 'turns': [], 'speak': []}
    # To add an empty bar between Average and rest of bars,
    #  and to add an empty bar at the end for clearer legend positioning.
    labels += ['', 'Average', '.']

    def add_member(member):
        # Add data to dictionary for Bargraph input
        # data_dict['week_num'] += weeks
        data_dict['labels'] += labels
        data_dict['member'] += [member for label in labels]
        for label in labels:
            if label != 'Average':
                if label in participation_values[member]:
                    data_dict['turns'] += [participation_values[member][label]['turns']]
                    data_dict['speak'] += [participation_values[member][label]['speak']]
                else:  # If member had no data for that week
                    data_dict['turns'] += [0]
                    data_dict['speak'] += [0]
            else:
                    data_dict['turns'] += [participation_values[member]['Average']['turns']]
                    data_dict['speak'] += [participation_values[member]['Average']['speak']]
    if member:
        # Add 'You' first so that 'You' is on bottom of bar chart
        add_member(member)
        for key in participation_values:
            if key != member:
                add_member(key)
    else:
        for key in participation_values:
            add_member(key)

    plot = stack_bar(data_dict)
    return plot 
开发者ID:HumanDynamics,项目名称:openbadge-analysis,代码行数:53,代码来源:participation.py


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