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


Python pygal.Line方法代码示例

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


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

示例1: twoline

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def twoline(file_name, title, line1, line1_label, line2, line2_label, x_labels):
    """
    Line1 is a list of data points
    Line2 is a list of data points
    x_labels are labels that correspond to the data points in line1 and line2

    Example call:
    line_graph.twoline("pynet-rtr1-octets.svg", "pynet-rtr1 Fa4 Input/Output Bytes",
        in_octets_list, "In Octets", out_octets_list, "Out Octets", x_labels_list):
    """
    line_chart = pygal.Line(include_x_axis=True)
    line_chart.title = title
    line_chart.x_labels = x_labels
    line_chart.add(line1_label, line1)
    line_chart.add(line2_label, line2)
    line_chart.render_to_file(file_name)
    return True 
开发者ID:ktbyers,项目名称:python_course,代码行数:19,代码来源:line_graph.py

示例2: twoline

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def twoline(file_name, title, line1, line1_label, line2, line2_label, x_labels):
    '''
    Line1 is a list of data points

    Line2 is a list of data points

    x_labels are labels that correspond to the data points in line1 and line2

    Example call:
    line_graph.twoline("pynet-rtr1-octets.svg", "pynet-rtr1 Fa4 Input/Output Bytes",
        in_octets_list, "In Octets", out_octets_list, "Out Octets", x_labels_list):

    '''

    line_chart = pygal.Line(include_x_axis=True)

    line_chart.title = title
    line_chart.x_labels = x_labels
    line_chart.add(line1_label, line1)
    line_chart.add(line2_label, line2)

    line_chart.render_to_file(file_name)

    return True 
开发者ID:ktbyers,项目名称:pynet,代码行数:26,代码来源:line_graph.py

示例3: twoline

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def twoline(file_name, title, line1, line1_label, line2, line2_label, x_labels):
    '''
    Line1 is a list of data points

    Line2 is a list of data points

    x_labels are labels that correspond to the data points in line1 and line2

    Example call:
    line_graph.twoline("pynet-rtr1-octets.svg", "pynet-rtr1 Fa4 Input/Output Bytes", 
        in_octets_list, "In Octets", out_octets_list, "Out Octets", x_labels_list):
                
    '''

    line_chart = pygal.Line(include_x_axis=True)
    
    line_chart.title = title
    line_chart.x_labels = x_labels
    line_chart.add(line1_label, line1)
    line_chart.add(line2_label,  line2)
    
    line_chart.render_to_file(file_name)
   
    return True 
开发者ID:ktbyers,项目名称:pynet,代码行数:26,代码来源:line_graph.py

示例4: buildChart

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def buildChart(data):
    '''Build the chard from array data'''
    v_lst=[]
    ts_lst=[]
    for row in data:
#        print row["start_date"]["timestamp"], row["subject"]["attribute"]["value"]
        v_lst.append(float(row["subject"]["attribute"]["value"]))
        ts_lst.append(UTCStrToLDT(row["start_date"]["timestamp"]))


    line_chart = pygal.Line()
    line_chart.title = 'Temperature'
    line_chart.y_title="Degrees C"
    line_chart.x_title="Timestamp (hover over to display date)"
    #need to reverse order to go from earliest to latest
    ts_lst.reverse()
    line_chart.x_labels = ts_lst
    #need to reverse order to go from earliest to latest
    v_lst.reverse()
    line_chart.add('Air Temp', v_lst)
    line_chart.render_to_file('/home/pi/MVP/web/temp_chart.svg') 
开发者ID:futureag,项目名称:mvp,代码行数:23,代码来源:TempChart.py

示例5: buildChart

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def buildChart(data):
    '''Build the chard from array data'''
    v_lst=[]
    ts_lst=[]
    for row in data:
#        print row["start_date"]["timestamp"], row["subject"]["attribute"]["value"]
        v_lst.append(float(row["subject"]["attribute"]["value"]))
        ts_lst.append(row["start_date"]["timestamp"])


    line_chart = pygal.Line()
    line_chart.title = 'Humidity'
    line_chart.y_title="Percent"
    line_chart.x_title="Timestamp (hover over to display date)"
    #need to reverse order to go from earliest to latest
    ts_lst.reverse()
    line_chart.x_labels = ts_lst
    #need to reverse order to go from earliest to latest
    v_lst.reverse()
    line_chart.add('Humidity', v_lst)
    line_chart.render_to_file('/home/pi/MVP/web/humidity_chart.svg') 
开发者ID:futureag,项目名称:mvp,代码行数:23,代码来源:HumidityChart.py

示例6: generate_line_chart

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def generate_line_chart(backups, cid, email, aid):
    """
    Generates a pygal line_chart given a list of backups
    """
    points, timestamps = _get_graph_points(backups, cid, email, aid)

    line_chart = pygal.Line(disable_xml_declaration=True,
                            human_readable=True,
                            legend_at_bottom=True,
                            pretty_print=True,
                            show_legend=False
                            )
    line_chart.title = 'Lines/Minutes Ratio Across Backups: {0}'.format(email)
    line_chart.add('Backups', points)
    line_chart.x_labels = timestamps
    return line_chart 
开发者ID:okpy,项目名称:ok,代码行数:18,代码来源:analyze.py

示例7: plot_graph

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def plot_graph(args):
    speedup_chart = pygal.Line(x_title='gpus', y_title='speedup', logarithmic=True)
    speedup_chart.x_labels = map(str, series(args.worker_count * args.gpu_count))
    speedup_chart.add('ideal speedup', series(args.worker_count * args.gpu_count))
    for net in args.networks:
        image_single_gpu = net.gpu_speedup[1] if 1 in net.gpu_speedup or not net.gpu_speedup[1] else 1
        y_values = [each / image_single_gpu for each in net.gpu_speedup.values()]
        LOGGER.info('%s: image_single_gpu:%.2f' % (net.name, image_single_gpu))
        LOGGER.debug('network:%s, y_values: %s' % (net.name, ' '.join(map(str, y_values))))
        speedup_chart.add(net.name, y_values \
            , formatter=lambda y_val, img=copy.deepcopy(image_single_gpu), batch_size=copy.deepcopy(
            net.batch_size): 'speedup:%.2f, img/sec:%.2f, batch/gpu:%d' % \
            (0 if y_val is None else y_val, 0 if y_val is None else y_val * img, batch_size))
    speedup_chart.render_to_file(log_loc + '/speedup.svg') 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:16,代码来源:benchmark.py

示例8: getEcsMetric

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def getEcsMetric(metric, uid, key, userid, instanceid):
    clt = client.AcsClient(uid,key,'cn-qingdao')
    startTime=datetime.datetime.now() - datetime.timedelta(hours=1)
    startTimeStr=startTime.strftime("%Y-%m-%d %H:%M:%S")
    request = QueryMetricRequest.QueryMetricRequest()
    request.set_accept_format('json')
    request.set_Project('acs_ecs')
    request.set_Metric(metric)
    request.set_StartTime(startTimeStr)
    request.set_Dimensions("{userId:'%s', instanceId:'%s'}" % (userid,instanceid))
    ret = clt.do_action(request)
    print(ret)
    data_json = json.loads(ret)
    rawdata = data_json["Datapoints"]["Datapoint"]
    for i in range(len(rawdata)):
        formatdata = (str(rawdata[i]["timestamp"]))[:10]
        txt_time = datetime.datetime.fromtimestamp(int(formatdata)).strftime('%Y-%m-%d %H:%M:%S')
        txt_t.append(txt_time)
        txt_content.append(rawdata[i]["Average"])
        txt_id = '%s' % (instanceid)

    line_chart = pygal.Line()
    line_chart.title = txt_id
    line_chart.x_labels = map(str, txt_content)
    line_chart.add(txt_id, txt_content)
    line_chart.render_to_file('ecs.svg') 
开发者ID:bbotte,项目名称:bbotte.github.io,代码行数:28,代码来源:aliyun_picture.py

示例9: pic

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def pic(self):
        line_chart = pygal.Line()
        line_chart.title = txt_id
        line_chart.x_labels = map(str, txt_t)
        line_chart.add(txt_id, txt_a)
        line_chart.render_to_file('bar_chart.svg') 
开发者ID:bbotte,项目名称:bbotte.github.io,代码行数:8,代码来源:pic_ali.py

示例10: user_graph

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def user_graph():
    hours = int(request.args.get('hours', 24))
    since = datetime.now() - timedelta(hours=hours)

    stats_query = db.session.query(Bridge).filter(Bridge.created > since).filter(Bridge.enabled == 1).with_entities(
            Bridge.created)

    base_count_query = db.session.query(func.count(Bridge.id)).scalar()

    df = pd.read_sql(stats_query.statement, stats_query.session.bind)
    df.set_index(['created'], inplace=True)
    df['count'] = 1

    # app.logger.info(df)

    # df.groupby(level=0).sum()

    r = df.resample('d').sum()
    r = r.fillna(0)
    r['cum_sum'] = r['count'].cumsum() + base_count_query

    # app.logger.info(r)

    users = r['cum_sum'].tolist()
    # app.logger.info(users)

    chart = pygal.Line(title=f"# of Users ({timespan(hours)})",
                       stroke_style={'width': 5},
                       show_legend=False)
    chart.add('Users', users, fill=True, show_dots=False)

    return chart.render_response() 
开发者ID:foozmeat,项目名称:moa,代码行数:34,代码来源:app.py

示例11: draw_line

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def draw_line(x_data, y_data, title, y_legend):
    xy_map = []
    for x, y in groupby(sorted(zip(x_data, y_data)), key=lambda _: _[0]):  # 2
        y_list = [v for _, v in y]
        xy_map.append([x, sum(y_list) / len(y_list)])  # 3
    x_unique, y_mean = [*zip(*xy_map)]  # 4
    line_chart = pygal.Line()
    line_chart.title = title
    line_chart.x_labels = x_unique
    line_chart.add(y_legend, y_mean)
    line_chart.render_to_file(title + '.svg')
    return line_chart

# 绘制2017年前11个月的日均值 
开发者ID:DeqianBai,项目名称:Python-Project,代码行数:16,代码来源:btc_close_2017.py

示例12: main

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def main(argv):

    label_list = None
    csv_list = None

    try:
        opts, args = getopt.getopt(argv, "", ["labels=","csv=","file=","maxgpu="])
    except getopt.GetoptError:
        print("Incorrect args")
        sys.exit(2)

    for opt, arg in opts:
        if opt == "--labels":
            label_list = arg
        elif opt == "--csv":
            csv_list = arg
        elif opt == "--file":
            out_file = arg
        elif opt == "--maxgpu":
            max_gpu = int(arg)
            
    if(label_list == None or csv_list == None or out_file == None or max_gpu == None):
        print("Incorrect args")
        sys.exit(2)

    labels = label_list.split(",")
    map(str.strip, labels)

    csv_files = csv_list.split(",")
    map(str.strip, csv_files)

    line_chart = pygal.Line(logarithmic=True, truncate_legend=100, legend_at_bottom=True)
    line_chart.title = "Deep Learning Frameworks - Performance Comparison"
    
    num_runs = math.ceil(math.log(max_gpu,2)) + 1
    x = np.arange(0,num_runs)
    x = np.power(2,x)
    x[-1] = max_gpu
    
    line_chart.x_labels = map(str, x.tolist())
    
    # Add ideal plot
    ideal = np.copy(x)
    line_chart.add('Ideal', ideal.tolist() )

    index = 0
    for csv_file in csv_files:
        with open(csv_file, mode='r') as infile:
            reader = csv.reader(infile, delimiter=',')
            baseline = 0
            yval = np.empty([0])
            for row in reader:
                if(len(row) == 2):
                    if baseline == 0:
                        baseline = float(row[1])
                    yval = np.append(yval, float(row[1])/baseline)
            line_chart.add(labels[index], yval.tolist(), formatter= lambda speedup, images_per_gpu=baseline: 'Speedup: %0.2f, Images/Sec: %0.2f' % (speedup, images_per_gpu*speedup))
            index += 1


    line_chart.render_to_file(out_file) 
开发者ID:awslabs,项目名称:deeplearning-benchmark,代码行数:63,代码来源:plotgraph.py

示例13: initStatusChart

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def initStatusChart(check_item, isShortTerm=True):
    statistics = CheckItemStatistics(check_item)
    if isShortTerm:
        data = statistics.getShortTermStatusData()
        # data elements: [date_list, normal_list, warning_list, critical_list, term_month_count]
        term_month_count = data[4]
        title = 'Status statistics in short term(%d months)' % (term_month_count)

    else:
        data = statistics.getLongTermStatusData()
        # data elements: [date_list, normal_list, warning_list, critical_list, term_month_count]
        term_month_count = data[4]
        title = 'Status statistics in long term(%d months)' % (term_month_count)

    date_list = data[0]
    date_list_short_format = getDatesInShortFormat(date_list)
    key_date_list_short_format = getDatesInShortFormat(getKeyDates(date_list))
    normal_list = data[1]
    warning_list = data[2]
    critical_list = data[3]

    custom_style = Style(colors=(
        '#b6e354'  # green
        , '#fd971f'  # yellow
        , '#DC3912'  # red
        ))
    chart = pygal.Line(style=custom_style, legend_at_bottom=True, legend_box_size=18)
    SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
    chart.js = [os.path.join(SITE_ROOT, "static/js/", "svg.jquery.js"),
                os.path.join(SITE_ROOT, "static/js/", "pygal-tooltips.js")]
    if isShortTerm:
        chart.height = 420
        chart.width = 900
    else:
        chart.height = 420
        chart.width = 2000
    chart.disable_xml_declaration = True  # disable xml root node
    chart.x_label_rotation = 30
    chart.title = title
    chart.x_title = 'Timeline'
    chart.y_title = 'Status count'

    chart.x_labels = map(str, date_list_short_format)
    chart.x_labels_major = key_date_list_short_format
    chart.add('Normal count', normal_list)
    chart.add('Warning count', warning_list)
    chart.add('Critical count', critical_list)

    return chart 
开发者ID:harryliu,项目名称:edwin,代码行数:51,代码来源:views.py

示例14: initValueChart

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def initValueChart(check_item, isShortTerm=True):
    statistics = CheckItemStatistics(check_item)
    if isShortTerm:
        data = statistics.getShortTermValueData()
        term_month_count = data[6]
        # data elements: [date_list, avg_value_list, min_value_list, max_value_list, warning_limit_list, critical_limit_list, term_month_count]
        title = 'Value statistics in short term(%d months)' % (term_month_count)
    else:
        data = statistics.getLongTermValueData()
        # data elements: [date_list, avg_value_list, min_value_list, max_value_list, warning_limit_list, critical_limit_list, term_month_count]
        term_month_count = data[6]
        title = 'Value statistics in long term(%d months)' % (term_month_count)

    date_list = data[0]
    date_list_short_format = getDatesInShortFormat(date_list)
    key_date_list_short_format = getDatesInShortFormat(getKeyDates(date_list))
    avg_value_list = data[1]
    min_value_list = data[2]
    max_value_list = data[3]
    warning_limit_list = data[4]
    critical_limit_list = data[5]

    custom_style = Style(colors=(
        '#fd971f'  # yellow--warning
        , '#DC3912'  # red--critical
        , '#6c71c4'  # min
        , '#8000FF'  # max
        , '#00FFFF'  # avg
        ))
    chart = pygal.Line(style=custom_style, legend_at_bottom=True, legend_box_size=18)
    SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
    chart.js = [os.path.join(SITE_ROOT, "static/js/", "svg.jquery.js"),
                os.path.join(SITE_ROOT, "static/js/", "pygal-tooltips.js")]
    if isShortTerm:
        chart.height = 420
        chart.width = 900
    else:
        chart.height = 700
        chart.width = 2000
    chart.disable_xml_declaration = True  # disable xml root node
    chart.x_label_rotation = 30
    chart.title = title
    chart.x_title = 'Timeline'
    chart.y_title = 'Value'

    chart.x_labels = map(str, date_list_short_format)
    chart.x_labels_major = key_date_list_short_format
    chart.add('Warning limit', warning_limit_list)
    chart.add('Critical limit', critical_limit_list)
    chart.add('Min value', min_value_list)
    chart.add('Max value', max_value_list)
    chart.add('Avg value', avg_value_list)

    return chart


# http://127.0.0.1:5000/items/UNIT_TEST_NONNUMERICAL
# http://127.0.0.1:5000/items/UNIT_TEST_NUMERICAL 
开发者ID:harryliu,项目名称:edwin,代码行数:60,代码来源:views.py

示例15: raw_svgs

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import Line [as 别名]
def raw_svgs():
    chart = pygal.Line(legend_at_bottom=True, legend_box_size=18)

    # =======================================
    # Declare the location of svg.jquery.js and pygal-tooltips.js in server side.
    # =======================================
    # It must be declare in server side, not html file
    # if not declare in server, by default it will load the two js files located in http://kozea.github.com/pygal.js. And it will slow down the page loading

    # 1, It works, load local js files
    SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
    chart.js = [os.path.join(SITE_ROOT, "static/js/", "svg.jquery.js"),
                os.path.join(SITE_ROOT, "static/js/", "pygal-tooltips.js")]

    # 2.a, It Works, but it is ugly because it use local absolute http url
    # chart.js =['http://127.0.0.1:5000/static/js/svg.jquery.js',
    #     'http://127.0.0.1:5000/static/js/pygal-tooltips.js']

    # 2.b, works, use local CDN absolute http url
    # chart.js =['http://another_server/pygal-tooltips.js',
    #     'http://another_server/svg.jquery.js']

    # 3, Does not work, error raised at visiting, IOError: [Errno 2] No such file
    # chart.js = [url_for('static', filename='js/svg.jquery.js'),
    #            url_for('static', filename='js/pygal-tooltips.js')]

    # disable xml root node
    chart.disable_xml_declaration = True
    chart.title = 'Browser usage evolution (in %)'
    chart.width = 2000
    chart.height = 2000
    chart.x_labels = map(str, range(2002, 2013))
    chart.add('Firefox', [None, None, 0, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1])
    chart.add('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3])
    chart.add('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
    chart.add('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5])

    svg_xml = chart.render()
    svg_xml = '<svg  style="width:2000px" ' + svg_xml[4:]
    svg_xml1 = svg_xml[:100]
    response = make_response(render_template('test_svg.html', title=svg_xml1, svg_xml=svg_xml))
    # response.headers['Content-Type']='image/svg+xml' 不能设置Content-Type为svg模式
    return response 
开发者ID:harryliu,项目名称:edwin,代码行数:45,代码来源:views.py


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