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