• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python simpleplot.plot_lines函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中simpleplot.plot_lines函数的典型用法代码示例。如果您正苦于以下问题:Python plot_lines函数的具体用法?Python plot_lines怎么用?Python plot_lines使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: create_plots

def create_plots(begin, end, stride):
    """ 
    Plot the function double, square, and exp
    from beginning to end using the provided stride
    
    The x-coordinates of the plotted points start
    at begin, terminate at end and are spaced by 
    distance stride
    """
    
    # generate x coordinates for plot points
    x_coords = []
    current_x = begin
    while current_x < end:
        x_coords.append(current_x)
        current_x += stride
        
    # compute list of (x, y) coordinates for each function
    double_plot = [(x_val, double(x_val)) for x_val in x_coords]
    square_plot = [(x_val, square(x_val)) for x_val in x_coords]
    exp_plot = [(x_val, exp(x_val)) for x_val in x_coords]
    
    # plot the list of points
    simpleplot.plot_lines("Plots of three functions", 600, 400, "x", "f(x)",
                         [double_plot, square_plot, exp_plot], 
                         True, ["double", "square", "exp"])
开发者ID:SyncMr,项目名称:OtherLearnings,代码行数:26,代码来源:Plot_Graph_user40_Q6cjXA4gqG_0.py


示例2: plot_performance

def plot_performance(plot_length, plot_type):
    """
    Build list that estimates running of physics update for ball_list
    """

    simulation = Simulation()
    plot = []
    
    for index in range(10, plot_length):
        
        # add a ball to ball_list
        while simulation.num_balls() != index:
            simulation.add_ball([random.randrange(CANVAS_WIDTH), random.randrange(CANVAS_HEIGHT)])
        
        # run update for all balls, num_updates times
        start_time = time.time()
        simulation.update()
        estimated_time = (time.time() - start_time) / float(NUM_UPDATES)
        
        if plot_type == TIME_PLOT:
            plot.append([index, estimated_time])
        else:
            plot.append([index, estimated_time / (index)])
    
    if plot_type == TIME_PLOT:
        simpleplot.plot_lines("Running time for linear update", 400, 400, "# balls", "time to update", [plot])    
    else:
        simpleplot.plot_lines("Comparison of running time to linear function", 400, 400, "# balls", "ratio", [plot])    
开发者ID:novneetnov,项目名称:Principles-Of-Computing---II,代码行数:28,代码来源:poc_physics_linear.py


示例3: run_simulations

def run_simulations():
    """
    Run simulations for several possible bribe increments
    """
    plot_type = LOGLOG
    days = 120
    inc_0 = greedy_boss(days, 0, plot_type)
    graph_1 = []
    graph_2 = []
    graph_3 = []
    graph_4 = []
    for point in inc_0:
        d = math.exp(point[0])
        graph_1.append((point[0], math.log(math.exp(0.095 * d))))
        #graph_2.append((point[0], math.log(95 * d * d)))
        #graph_3.append((point[0], math.log(math.exp(9.5 * d))))
        #graph_4.append((point[0], math.log(9.5 * d * d * d *d)))
    
    #inc_500 = greedy_boss(days, 500, plot_type)
    #inc_1000 = greedy_boss(days, 1000, plot_type)
    #inc_2000 = greedy_boss(days, 2000, plot_type)
#    simpleplot.plot_lines("Greedy boss", 600, 600, "days", "total earnings", 
#                          [inc_0, inc_500, inc_1000, inc_2000], False,
#                         ["Bribe increment = 0", "Bribe increment = 500",
#                          "Bribe increment = 1000", "Bribe increment = 2000"]
#                         )
    simpleplot.plot_lines("Greedy boss", 600, 600, "days", "total earnings", 
                          [inc_0, graph_1], False,
                         ["Bribe increment = 0", "graph_1"]
                         )
    x1 = -1
    y1 = -1
开发者ID:TogusaRusso,项目名称:codesculptorlabs,代码行数:32,代码来源:PoC_Week5_GreedyBoss.py


示例4: q1_legend

def q1_legend(low, high):
    xvals = []
    slow = []
    fast = []
    for num_clusters in range(low, high, 100):
        xvals.append(num_clusters)
        cluster_list = gen_random_clusters(num_clusters)
        
        time1 = time.time()
        slow_closest_pair(cluster_list)
        time2 = time.time()
        slow.append(time2 - time1)
        
        time1 = time.time()
        fast_closest_pair(cluster_list)
        time2 = time.time()
        fast.append(time2 - time1)
        
    yvals1 = slow
    yvals2 = fast
    curve1 = [[xvals[idx], yvals1[idx]] for idx in range(len(xvals))]
    curve2 = [[xvals[idx], yvals2[idx]] for idx in range(len(xvals))]
    print curve1
    print curve2
    simpleplot.plot_lines("The running times of closest-pair-find functions", 
                          800, 600, "the number of initial clusters",
                          "the running time of the function in seconds",
                          [curve1, curve2], True, 
                          ["slow_closest_pair", 
                           "fast_closest_pair"])
开发者ID:hieast,项目名称:PlayGround,代码行数:30,代码来源:alg_project3_solution.py


示例5: test

def test():
    """
    Testing code for resources_vs_time
    """
    ## q10, q11
    data1 = resources_vs_time(-1, 45)
    data2 = resources_vs_time(1.0, 100)
    simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [data1, data2])
开发者ID:hrpatel,项目名称:coursera,代码行数:8,代码来源:homework.py


示例6: make_plot

def make_plot(fun1, fun2, plot_length):
    """
    Create a plot relating the growth of fun1 vs. fun2
    """
    answer = []
    for index in range(10, plot_length):
        answer.append([index, fun1(index) / float(fun2(index))])
    simpleplot.plot_lines("Growth rate comparison", 300, 300, "n", "f(n)/g(n)", [answer])
开发者ID:maple03,项目名称:principlescomputing2,代码行数:8,代码来源:growth_rate.py


示例7: test

def test():
    """
    Testing code for resources_vs_time
    """
    data1 = resources_vs_time(0.5, 20)
    data2 = resources_vs_time(1.5, 10)
    print data1
    print data2
    simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [data1, data2])
开发者ID:creasyw,项目名称:Courses,代码行数:9,代码来源:hw2.py


示例8: test

def test():
    """
    Testing code for resources_vs_time
    """
    data1 = resources_vs_time(1, 60)

    print data1

    simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [data1])
开发者ID:swengzju,项目名称:Principle-of-Computing-Coursera,代码行数:9,代码来源:wk1_hm1.py


示例9: test

def test():
    """
    Testing code for resources_vs_time
    """
    data1 = resources_vs_time(0.0, 50)
    data2 = resources_vs_time(1.0, 10)
    data3 = resources_vs_time(2.0, 10)
    data4 = resources_vs_time(0.5, 10)
    print data1
    simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [data1])
开发者ID:epson121,项目名称:principles_of_computing,代码行数:10,代码来源:q2.py


示例10: plot_example

def plot_example(length):
    global counter
    poly_func = []
    fib_func = []
    for iter in range(length):
        counter = 0
        poly_func.append([iter, 2 * iter - 1])
        answer = memoized_fib(iter, {0 : 0, 1 : 1})
        fib_func.append([iter, counter])
    simpleplot.plot_lines("Recurrence solutions", 600, 600, "number", "value", [poly_func, fib_func], legends = ["Ideal. Plot", "Fib plot"])
开发者ID:novneetnov,项目名称:Principles-Of-Computing---II,代码行数:10,代码来源:fibonacci_memoized.py


示例11: plot_example

def plot_example(length):
    """
    Plot computed solutions to recurrences
    """
    rec_plot = []
    sol_plot = []
    sol = SOL_DICT[INDEX]
    for num in range(2, length):
        rec_plot.append([num, recur(num)])
        sol_plot.append([num, sol(num)])
    simpleplot.plot_lines("Recurrence solutions", 600, 600, "number", "value", [rec_plot, sol_plot], legends = ["Approx. Plot", "Ideal plot"])
开发者ID:novneetnov,项目名称:Principles-Of-Computing---II,代码行数:11,代码来源:poc_recurrence_plot.py


示例12: run_strategy

def run_strategy(strategy_name, time, strategy):
    """
    Run a simulation for the given time with one strategy.
    """
    state = simulate_clicker(provided.BuildInfo(), time, strategy)
    print "\n", strategy_name, ":\n", state

    # Plot total cookies over time
    history = state.get_history()
    history = [(item[0], item[3]) for item in history]
    simpleplot.plot_lines(strategy_name, 1000, 400, "Time", "Total Cookies", [history], True)
开发者ID:iainharlow,项目名称:Python-Games-and-Utilities,代码行数:11,代码来源:CookieClickerStrategies.py


示例13: init

def init():
    global balls
    global fps
    global freezed
    global nb_balls
    global nb_frames_drawed
    global nb_seconds
    global results
    global to_next_step

    if len(list_nb_balls) == 0:
        timer.stop()

        results = dict_to_ordered_list(results)

        print('Results: {' + ', '
              .join(['%d: %d' % result for result in results]) + '}')

        try:
            frame.stop()
        except Exception as e:  # to avoid simpleguitk failed
            print('frame.stop():' + str(e))

        try:
            simpleplot.plot_lines('Stress Balls', 800, 650,
                                  '# balls', 'FPS',
                                  (results, ), True)
            if SIMPLEGUICS2PYGAME:
                simpleplot._block()
        except Exception as e:  # to avoid fail if no simpleplot
            print('simpleplot.plot_lines():' + str(e))

        return

    if list_nb_balls:
        nb_balls = list_nb_balls.pop(0)

    fps = 0
    freezed = False
    nb_frames_drawed = 0
    nb_seconds = 0
    to_next_step = False

    balls = tuple([Ball([47 + n % (WIDTH - 100),
                         47 + n % (HEIGHT - 100)],  # position
                        19 + n % 11,  # radius
                        n_to_rgba((n + 1) % len(RGB_COLORS),
                                  .2 + float(n % 13)/15),  # color of border
                        n_to_rgba((n + 2) % len(RGB_COLORS),
                                  .2 + float((n + 3) % 14)/17),  # fill color
                        [3 + n % 7, 2 + n % 5],  # velocity
                        (n + 2) % 6)  # shape
                   for n in range(nb_balls)])
开发者ID:Yesterday69,项目名称:Django-blog,代码行数:53,代码来源:Stress_Balls_reverse.py


示例14: test

def test():
    """
    Testing code for resources_vs_time
    """
    loop = 20
    data1 = resources_vs_time(1.0, loop)
    #data2 = resources_vs_time(0.5, loop)
    #data3 = resources_vs_time(1.0, loop)
    #data4 = resources_vs_time(2.0, loop)
    print data1
    #print data2
    simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [data1])
开发者ID:kebingyu,项目名称:codeskulptorproject,代码行数:12,代码来源:resources_vs_time.py


示例15: run_strategy

def run_strategy(strategy_name, time, strategy):
    """
    Run a simulation for the given time with one strategy.
    """
    state = simulate_clicker(provided.BuildInfo(), time, strategy)
    print strategy_name, ":", state

    # Plot total cookies over time
    # Uncomment out the lines below to see a plot of total cookies vs. time
    # Be sure to allow popups, if you do want to see it
    history = state.get_history()
    history = [(item[0], item[3]) for item in history]
    simpleplot.plot_lines(strategy_name, 1000, 400, 'Time', 'Total Cookies', [history], True)
开发者ID:ryanjamesmcgill,项目名称:cookie-clicker,代码行数:13,代码来源:CookieClicker.py


示例16: run_strategy

def run_strategy(strategy_name, time, strategy):
    """
    Runs a simulation for the given time with the given strategy. Prints final
    strategy statistics to the console and graphs the time versus total cookies.
    """
    state = simulate_clicker(provided.BuildInfo(), time, strategy)
    print strategy_name, " Strategy:", state

    # Plot total cookies over time
    history = state.get_history()
    history = [(item[0], item[3]) for item in history]
    simpleplot.plot_lines(strategy_name, 1000, 400, 'Time', 'Total Cookies', [
        history], True)
开发者ID:phaedraa,项目名称:Games,代码行数:13,代码来源:CookieClickerSimulator.py


示例17: run_simulations

def run_simulations():
    """
    Run simulations for several possible bribe increments
    """
    plot_type = STANDARD
    days = 80
    inc_0 = greedy_boss(days, 0, plot_type)
    #inc_500 = greedy_boss(days, 500, plot_type)
    #inc_1000 = greedy_boss(days, 1000, plot_type)
    #inc_2000 = greedy_boss(days, 2000, plot_type)
    simpleplot.plot_lines("Greedy boss", 600, 600, "days", "total earnings",
                          [inc_0], False,
                         ["Bribe increment = 0"])
开发者ID:novneetnov,项目名称:Principles-Of-Computing---I,代码行数:13,代码来源:poc_greedy_boss.py


示例18: test

def test():
    """
    Testing code for resources_vs_time
    """
    data1 = resources_vs_time(0.5, 20, STANDARD)
    data2 = resources_vs_time(1.5, 10, STANDARD)
    #print data1
    #print data2
    
    #test1 = [[1.0, 1], [1.75, 2.5], [2.41666666667, 4.5], [3.04166666667, 7.0], [3.64166666667, 10.0], [4.225, 13.5], [4.79642857143, 17.5], [5.35892857143, 22.0], [5.91448412698, 27.0], [6.46448412698, 32.5], [7.00993867244, 38.5], [7.55160533911, 45.0], [8.09006687757, 52.0], [8.62578116328, 59.5], [9.15911449661, 67.5], [9.69036449661, 76.0], [10.2197762613, 85.0], [10.7475540391, 94.5], [11.2738698286, 104.5], [11.7988698286, 115.0]]
    #test2 = [[1.0, 1], [2.25, 3.5], [3.58333333333, 7.5], [4.95833333333, 13.0], [6.35833333333, 20.0], [7.775, 28.5], [9.20357142857, 38.5], [10.6410714286, 50.0], [12.085515873, 63.0], [13.535515873, 77.5]]
    
    print "\n###############  Question 1  ##################"
    question1_a = resources_vs_time(0.0, 10, STANDARD)
    question1_b = resources_vs_time(1.0, 10, STANDARD)
    #print question1_a
    print question1_b
    #simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [data1, data2])
    #simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [test1, test2])

    
    print "\n###############  Question 2  ##################"
    question2_a = resources_vs_time(0.0, 100, STANDARD)
    question2_b = resources_vs_time(0.5, 18, STANDARD)
    question2_c = resources_vs_time(1.0, 14, STANDARD)
    question2_d = resources_vs_time(2.0, 10, STANDARD)
    #print question2_a
    #print question2_b
    #print question2_c
    #print question2_d
    simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [question2_a, question2_b, question2_c, question2_d])
    
    
    print "\n###############  Question 3  ##################"
    question3 = resources_vs_time(0.0, 10, LOGLOG)
    #print question3
    #simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [question3])
    
    
    print "\n###############  Question 7  ##################"
    question7 = resources_vs_time(1.0, 10, LOGLOG)
    print question7
    #simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [question1_b])
      
    print "\n###############  Question 9  ##################"
    question9a = resources_vs_time(1.0, 10, STANDARD)
    question9b = resources_vs_time(1.0, 20, STANDARD)
    print question9a
    print question9b
开发者ID:GeorgePapageorgakis,项目名称:Coursera-Projects,代码行数:49,代码来源:Simulator_Resource_generation_with_upgrades.py


示例19: test

def test():
    """
    Testing code for resources_vs_time
    """
    #data1 = resources_vs_time(0.5, 20)
    #data2 = resources_vs_time(1.5, 10)
    data1 = resources_vs_time(1.0, 60)
    data2 = rvt(1.0, 60)
    #data3 = resources_vs_time(1.0, 10)
    #data4 = resources_vs_time(2.0, 5)
    print data1
    #print data2
    #print data3
    #print data4
    simpleplot.plot_lines("Growth", 600, 600, "time", "total resources", [data1, data2])
开发者ID:wwwscopin,项目名称:Python,代码行数:15,代码来源:Cookie+Week1++Homework.py


示例20: plot

def plot(diagraph):
    """
    plot a diagraph
    """
    values = diagraph.values()
    summ = float(sum(values))
    logdiag = dict()
    for key,value in diagraph.items():
        if key != 0:
            key = math.log(key)
        value = math.log(value / summ)
        logdiag[key] = value
        
    simpleplot.plot_lines('A normalized distribution on a log/log scale', 400, 300,
                          'In degrees', 'Number of Nodes', [logdiag], True)
开发者ID:piratetwo,项目名称:git,代码行数:15,代码来源:Project+1+-+Degree+distributions+for+graphs.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python simplesqlite.SimpleSQLite类代码示例发布时间:2022-05-27
下一篇:
Python simplepath.parsePath函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap