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


Python simpleplot.plot_lines函数代码示例

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


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


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