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


Python pylab.legend方法代码示例

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


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

示例1: plot_learning_curve

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_learning_curve(train_sizes, train_scores, test_scores):
    """plot_learning_curve."""
    plt.figure(figsize=(15, 5))
    plt.title('Learning Curve')
    plt.xlabel("Training examples")
    plt.ylabel("AUC ROC")
    tr_ys = compute_stats(train_scores)
    te_ys = compute_stats(test_scores)
    plot_stats(train_sizes, tr_ys,
               label='Training score',
               color='navy')
    plot_stats(train_sizes, te_ys,
               label='Cross-validation score',
               color='orange')
    plt.grid(linestyle=":")
    plt.legend(loc="best")
    plt.show() 
开发者ID:fabriziocosta,项目名称:EDeN,代码行数:19,代码来源:estimator_utils.py

示例2: plot_it

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_it():
    '''
    helper function to gain insight on provided data sets background,
    using pylab
    '''
    data1 = [[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]]
    data2 = [[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]]
    time1 = [item[0] for item in data1]
    resource1 = [item[1] for item in data1]
    time2 = [item[0] for item in data2]
    resource2 = [item[1] for item in data2]
    
    # plot in pylab (total resources over time)
    pylab.plot(time1, resource1, 'o')
    pylab.plot(time2, resource2, 'o')
    pylab.title('Silly Homework')
    pylab.legend(('Data Set no.1', 'Data Set no.2'))
    pylab.xlabel('Current Time')
    pylab.ylabel('Total Resources Generated')
    pylab.show()

#plot_it() 
开发者ID:chubbypanda,项目名称:principles-of-computing,代码行数:24,代码来源:homework1.py

示例3: plot_question2

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_question2():
    '''
    graph of total resources generated as a function of time,
    for four various upgrade_cost_increment values
    '''
    for upgrade_cost_increment in [0.0, 0.5, 1.0, 2.0]:
        data = resources_vs_time(upgrade_cost_increment, 5)
        time = [item[0] for item in data]
        resource = [item[1] for item in data]
    
        # plot in pylab (total resources over time for each constant)
        pylab.plot(time, resource, 'o')
        
    pylab.title('Silly Homework')
    pylab.legend(('0.0', '0.5', '1.0', '2.0'))
    pylab.xlabel('Current Time')
    pylab.ylabel('Total Resources Generated')
    pylab.show()

#plot_question2()   


# Question 3 
开发者ID:chubbypanda,项目名称:principles-of-computing,代码行数:25,代码来源:homework1.py

示例4: plot_question3

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_question3():
    '''
    graph of total resources generated as a function of time;
    for upgrade_cost_increment == 0
    '''
    data = resources_vs_time(0.0, 100)
    time = [item[0] for item in data]
    resource = [item[1] for item in data]

    # plot in pylab on logarithmic scale (total resources over time for upgrade growth 0.0)
    pylab.loglog(time, resource)
        
    pylab.title('Silly Homework')
    pylab.legend('0.0')
    pylab.xlabel('Current Time')
    pylab.ylabel('Total Resources Generated')
    pylab.show()

#plot_question3()


# Question 4 
开发者ID:chubbypanda,项目名称:principles-of-computing,代码行数:24,代码来源:homework1.py

示例5: plot_question7

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_question7():
    '''
    graph of total resources generated as a function of time,
    for upgrade_cost_increment == 1
    '''
    data = resources_vs_time(1.0, 50)
    time = [item[0] for item in data]
    resource = [item[1] for item in data]
    a, b, c = pylab.polyfit(time, resource, 2)
    print 'polyfit with argument \'2\' fits the data, thus the degree of the polynomial is 2 (quadratic)'

    # plot in pylab on logarithmic scale (total resources over time for upgrade growth 0.0)
    #pylab.loglog(time, resource, 'o')

    # plot fitting function
    yp = pylab.polyval([a, b, c], time)
    pylab.plot(time, yp)
    pylab.scatter(time, resource)
    pylab.title('Silly Homework, Question 7')
    pylab.legend(('Resources for increment 1', 'Fitting function' + ', slope: ' + str(a)))
    pylab.xlabel('Current Time')
    pylab.ylabel('Total Resources Generated')
    pylab.grid()
    pylab.show() 
开发者ID:chubbypanda,项目名称:principles-of-computing,代码行数:26,代码来源:homework1.py

示例6: plot_entropy

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_entropy(self):
        """

        Returns:

        """
        try:
            import pylab as plt
        except ImportError:
            import matplotlib.pyplot as plt
        plt.plot(
            self.temperatures,
            self.eV_to_J_per_mol / self.num_atoms * self.get_entropy_p(),
            label="S$_p$",
        )
        plt.plot(
            self.temperatures,
            self.eV_to_J_per_mol / self.num_atoms * self.get_entropy_v(),
            label="S$_V$",
        )
        plt.legend()
        plt.xlabel("Temperature [K]")
        plt.ylabel("Entropy [J K$^{-1}$ mol-atoms$^{-1}$]") 
开发者ID:pyiron,项目名称:pyiron,代码行数:25,代码来源:thermo_bulk.py

示例7: plot_Geweke

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_Geweke(parameterdistribution,parametername):
    '''Input:  Takes a list of sampled values for a parameter and his name as a string
       Output: Plot as seen for e.g. in BUGS or PyMC'''
    import matplotlib.pyplot as plt

    # perform the Geweke test
    Geweke_values = _Geweke(parameterdistribution)

    # plot the results
    fig = plt.figure()
    plt.plot(Geweke_values,label=parametername)
    plt.legend()
    plt.title(parametername + '- Geweke_Test')
    plt.xlabel('Subinterval')
    plt.ylabel('Geweke Test')
    plt.ylim([-3,3])

    # plot the delimiting line
    plt.plot( [2]*len(Geweke_values), 'r-.')
    plt.plot( [-2]*len(Geweke_values), 'r-.') 
开发者ID:thouska,项目名称:spotpy,代码行数:22,代码来源:analyser.py

示例8: impose_legend_limit

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def impose_legend_limit(limit=30, axes="gca", **kwargs):
    """
    This will erase all but, say, 30 of the legend entries and remake the legend.
    You'll probably have to move it back into your favorite position at this point.
    """
    if axes=="gca": axes = _pylab.gca()

    # make these axes current
    _pylab.axes(axes)

    # loop over all the lines_pylab.
    for n in range(0,len(axes.lines)):
        if n >  limit-1 and not n==len(axes.lines)-1: axes.lines[n].set_label("_nolegend_")
        if n == limit-1 and not n==len(axes.lines)-1: axes.lines[n].set_label("...")

    _pylab.legend(**kwargs) 
开发者ID:Spinmob,项目名称:spinmob,代码行数:18,代码来源:_pylab_tweaks.py

示例9: _plotFMeasures

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def _plotFMeasures(fstepsize=.1,  stepsize=0.0005, start = 0.0, end = 1.0):
    """Plots 10 fmeasure Curves into the current canvas."""
    p = sc.arange(start, end, stepsize)[1:]
    for f in sc.arange(0., 1., fstepsize)[1:]:
        points = [(x, _fmeasureCurve(f, x)) for x in p
                  if 0 < _fmeasureCurve(f, x) <= 1.5]
        try:
            xs, ys = zip(*points)
            curve, = pl.plot(xs, ys, "--", color="gray", linewidth=0.8)  # , label=r"$f=%.1f$"%f) # exclude labels, for legend
            # bad hack:
            # gets the 10th last datapoint, from that goes a bit to the left, and a bit down
            datapoint_x_loc = int(len(xs)/2)
            datapoint_y_loc = int(len(ys)/2)
            # x_left = 0.05
            # y_left = 0.035
            x_left = 0.035
            y_left = -0.02
            pl.annotate(r"$f=%.1f$" % f, xy=(xs[datapoint_x_loc], ys[datapoint_y_loc]), xytext=(xs[datapoint_x_loc] - x_left, ys[datapoint_y_loc] - y_left), size="small", color="gray")
        except Exception as e:
            print e 

#colors = "gcmbbbrrryk"
#colors = "yyybbbrrrckgm"  # 7 is a prime, so we'll loop over all combinations of colors and markers, when zipping their cycles 
开发者ID:zhenv5,项目名称:breaking_cycles_in_noisy_hierarchies,代码行数:25,代码来源:plot_recallPrecision.py

示例10: main

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

    l2_base_dir = '/media/admin228/00027E210001A5BD/train_pytorch/change_detection/CMU/prediction_cons/l2_5,6,7/roc'
    cos_base_dir = '/media/admin228/00027E210001A5BD/train_pytorch/change_detection/CMU/prediction_cons/dist_cos_new_5,6,7/roc'
    CSF_dir = os.path.join(l2_base_dir)
    CSF_fig_dir = os.path.join(l2_base_dir,'fig.png')
    end_number = 22
    csf_conv5_l2_ls,csf_fc6_l2_ls,csf_fc7_l2_ls,x_l2 = get_csf_ls(l2_base_dir,end_number)
    csf_conv5_cos_ls,csf_fc6_cos_ls,csf_fc7_cos_ls,x_cos = get_csf_ls(cos_base_dir,end_number)
    Fig = pylab.figure()
    setFigLinesBW(Fig)
    #pylab.plot(x,csf_conv4_ls, color='k',label= 'conv4')
    pylab.plot(x_l2,csf_conv5_l2_ls, color='m',label= 'l2:conv5')
    pylab.plot(x_l2,csf_fc6_l2_ls, color = 'b',label= 'l2:fc6')
    pylab.plot(x_l2,csf_fc7_l2_ls, color = 'g',label= 'l2:fc7')
    pylab.plot(x_cos,csf_conv5_cos_ls, color='c',label= 'cos:conv5')
    pylab.plot(x_cos,csf_fc6_cos_ls, color = 'r',label= 'cos:fc6')
    pylab.plot(x_cos,csf_fc7_cos_ls, color = 'y',label= 'cos:fc7')
    pylab.legend(loc='lower right', prop={'size': 10})
    pylab.ylabel('RMS Contrast', fontsize=14)
    pylab.xlabel('Epoch', fontsize=14)
    pylab.savefig(CSF_fig_dir) 
开发者ID:gmayday1997,项目名称:SceneChangeDet,代码行数:24,代码来源:plot_contrast_sensitive.py

示例11: plot_sensor_data

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_sensor_data(self, title, timestamp, x, y, z):
        if not self.to_save and not self.to_show:
            return

        self.big_figure()
        pylab.grid("on")

        pylab.plot(timestamp, x, color='r', label='x')
        pylab.plot(timestamp, y, color='g', label='y')
        pylab.plot(timestamp, z, color='b', label='z')

        pylab.legend()

        pylab.title(title)
        pylab.xlabel('Time')
        pylab.ylabel('Amplitude') 
开发者ID:tonybeltramelli,项目名称:Deep-Spying,代码行数:18,代码来源:View.py

示例12: plot_data

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_data(self, title, data, xlabel, ylabel, colors=None, labels=None):
        if not self.to_save and not self.to_show:
            return

        self.big_figure()

        for i in range(0, len(data)):
            color = 'm' if colors is None else colors[i]

            if labels is None:
                pylab.plot(data[i], color=color)
            else:
                pylab.plot(data[i], color=color, label=labels[i])

        if labels is not None:
            pylab.legend()

        pylab.title(title)
        pylab.xlabel(xlabel)
        pylab.ylabel(ylabel) 
开发者ID:tonybeltramelli,项目名称:Deep-Spying,代码行数:22,代码来源:View.py

示例13: plot_signal_and_label

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_signal_and_label(self, title, timestamp, signal, label_timestamp, label):
        if not self.to_save and not self.to_show:
            return

        pylab.figure()

        pylab.plot(timestamp, signal, color='m', label='signal')

        for i in range(0, len(label_timestamp)):
            pylab.axvline(label_timestamp[i], color="k", label="{}: key {}".format(i, label[i]), ls='dashed')

        pylab.legend()

        pylab.title(title)
        pylab.xlabel('Time')
        pylab.ylabel('Amplitude') 
开发者ID:tonybeltramelli,项目名称:Deep-Spying,代码行数:18,代码来源:View.py

示例14: plot_barchart

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def plot_barchart(self, data, labels, colors, xlabel, ylabel, xticks, legendloc=1):
        self.big_figure()

        index = np.arange(len(data[0][0]))
        bar_width = 0.25

        pylab.grid("on", axis='y')
        pylab.ylim([0.5, 1.0])

        for i in range(0, len(data)):
            rects = pylab.bar(bar_width / 2 + index + (i * bar_width), data[i][0], bar_width,
                              alpha=0.5, color=colors[i],
                              yerr=data[i][1],
                              error_kw={'ecolor': '0.3'},
                              label=labels[i])

        pylab.legend(loc=legendloc, prop={'size': 12})

        pylab.xlabel(xlabel)
        pylab.ylabel(ylabel)
        pylab.xticks(bar_width / 2 + index + ((bar_width * (len(data[0]) + 1)) / len(data[0])), xticks) 
开发者ID:tonybeltramelli,项目名称:Deep-Spying,代码行数:23,代码来源:View.py

示例15: addqqplotinfo

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import legend [as 别名]
def addqqplotinfo(qnull,M,xl='-log10(P) observed',yl='-log10(P) expected',xlim=None,ylim=None,alphalevel=0.05,legendlist=None,fixaxes=False):    
    distr='log10'
    pl.plot([0,qnull.max()], [0,qnull.max()],'k')
    pl.ylabel(xl)
    pl.xlabel(yl)
    if xlim is not None:
        pl.xlim(xlim)
    if ylim is not None:
        pl.ylim(ylim)        
    if alphalevel is not None:
        if distr == 'log10':
            betaUp, betaDown, theoreticalPvals = _qqplot_bar(M=M,alphalevel=alphalevel,distr=distr)
            lower = -sp.log10(theoreticalPvals-betaDown)
            upper = -sp.log10(theoreticalPvals+betaUp)
            pl.fill_between(-sp.log10(theoreticalPvals),lower,upper,color="grey",alpha=0.5)
            #pl.plot(-sp.log10(theoreticalPvals),lower,'g-.')
            #pl.plot(-sp.log10(theoreticalPvals),upper,'g-.')
    if legendlist is not None:
        leg = pl.legend(legendlist, loc=4, numpoints=1)
        # set the markersize for the legend
        for lo in leg.legendHandles:
            lo.set_markersize(10)

    if fixaxes:
        fix_axes() 
开发者ID:MicrosoftResearch,项目名称:Azimuth,代码行数:27,代码来源:util.py


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