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


Python pylab.ylabel方法代码示例

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


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

示例1: error_bar_plot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def error_bar_plot(experiment_data, results, title="", ylabel=""):

    true_effect = experiment_data.true_effects.mean()
    estimators = list(results.keys())

    x = list(estimators)
    y = [results[estimator].ate for estimator in estimators]

    cis = [
        np.array(results[estimator].ci) - results[estimator].ate
        if results[estimator].ci is not None
        else [0, 0]
        for estimator in estimators
    ]
    err = [[abs(ci[0]) for ci in cis], [abs(ci[1]) for ci in cis]]

    plt.figure(figsize=(12, 5))
    (_, caps, _) = plt.errorbar(x, y, yerr=err, fmt="o", markersize=8, capsize=5)
    for cap in caps:
        cap.set_markeredgewidth(2)
    plt.plot(x, [true_effect] * len(x), label="True Effect")
    plt.legend(fontsize=12, loc="lower right")
    plt.ylabel(ylabel)
    plt.title(title) 
开发者ID:zykls,项目名称:whynot,代码行数:26,代码来源:mediator_utils.py

示例2: plot_clustering

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_clustering(x, y, title, mx=None, ymax=None, xmin=None, km=None):
    pylab.figure(num=None, figsize=(8, 6))
    if km:
        pylab.scatter(x, y, s=50, c=km.predict(list(zip(x, y))))
    else:
        pylab.scatter(x, y, s=50)

    pylab.title(title)
    pylab.xlabel("Occurrence word 1")
    pylab.ylabel("Occurrence word 2")

    pylab.autoscale(tight=True)
    pylab.ylim(ymin=0, ymax=1)
    pylab.xlim(xmin=0, xmax=1)
    pylab.grid(True, linestyle='-', color='0.75')

    return pylab 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:19,代码来源:plot_kmeans_example.py

示例3: plot_entropy

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_entropy():
    pylab.clf()
    pylab.figure(num=None, figsize=(5, 4))

    title = "Entropy $H(X)$"
    pylab.title(title)
    pylab.xlabel("$P(X=$coin will show heads up$)$")
    pylab.ylabel("$H(X)$")

    pylab.xlim(xmin=0, xmax=1.1)
    x = np.arange(0.001, 1, 0.001)
    y = -x * np.log2(x) - (1 - x) * np.log2(1 - x)
    pylab.plot(x, y)
    # pylab.xticks([w*7*24 for w in [0,1,2,3,4]], ['week %i'%(w+1) for w in
    # [0,1,2,3,4]])

    pylab.autoscale(tight=True)
    pylab.grid(True)

    filename = "entropy_demo.png"
    pylab.savefig(os.path.join(CHART_DIR, filename), bbox_inches="tight") 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:23,代码来源:demo_mi.py

示例4: plot_roc

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_roc(auc_score, name, tpr, fpr, label=None):
    pylab.clf()
    pylab.figure(num=None, figsize=(5, 4))
    pylab.grid(True)
    pylab.plot([0, 1], [0, 1], 'k--')
    pylab.plot(fpr, tpr)
    pylab.fill_between(fpr, tpr, alpha=0.5)
    pylab.xlim([0.0, 1.0])
    pylab.ylim([0.0, 1.0])
    pylab.xlabel('False Positive Rate')
    pylab.ylabel('True Positive Rate')
    pylab.title('ROC curve (AUC = %0.2f) / %s' %
                (auc_score, label), verticalalignment="bottom")
    pylab.legend(loc="lower right")
    filename = name.replace(" ", "_")
    pylab.savefig(
        os.path.join(CHART_DIR, "roc_" + filename + ".png"), bbox_inches="tight") 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:19,代码来源:utils.py

示例5: plot_fermi_dirac

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_fermi_dirac(self):
        """
        Plots the obtained eigenvalue vs occupation plot

        """
        try:
            import matplotlib.pylab as plt
        except ModuleNotFoundError:
            import matplotlib.pyplot as plt
        arg = np.argsort(self.eigenvalues)
        plt.plot(
            self.eigenvalues[arg], self.occupancies[arg], linewidth=2.0, color="blue"
        )
        plt.axvline(self.efermi, linewidth=2.0, linestyle="dashed", color="black")
        plt.xlabel("Energies (eV)")
        plt.ylabel("Occupancy")
        return plt 
开发者ID:pyiron,项目名称:pyiron,代码行数:19,代码来源:electronic.py

示例6: plot_equilibration

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_equilibration(temperature_next, strain_lst, nve_run_time_steps, project_parameter, debug_plot=True):
    if debug_plot:
        for strain in strain_lst:
            job_name = get_nve_job_name(
                temperature_next=temperature_next,
                strain=strain,
                steps_lst=project_parameter['nve_run_time_steps_lst'],
                nve_run_time_steps=nve_run_time_steps
            )
            ham_nve = project_parameter['project'].load(job_name)
            plt.plot(ham_nve['output/generic/temperature'], label='strain: ' + str(strain))
            plt.axhline(np.mean(ham_nve['output/generic/temperature'][-20:]), linestyle='--', color='red')
            plt.axvline(range(len(ham_nve['output/generic/temperature']))[-20], linestyle='--', color='black')
            plt.legend()
            plt.xlabel('timestep')
            plt.ylabel('Temperature K')
            plt.legend()
            plt.show() 
开发者ID:pyiron,项目名称:pyiron,代码行数:20,代码来源:interfacemethod.py

示例7: check_for_holes

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def check_for_holes(temperature_next, strain_value_lst, nve_run_time_steps, project_parameter, debug_plot=True):
    max_lst, mean_lst = get_voronoi_volume(
        temperature_next=temperature_next,
        strain_lst=strain_value_lst,
        nve_run_time_steps=nve_run_time_steps,
        project_parameter=project_parameter
    )
    if debug_plot:
        plt.plot(strain_value_lst, mean_lst, label='mean')
        plt.plot(strain_value_lst, max_lst, label='max')
        plt.axhline(np.mean(mean_lst) * 2, color='black', linestyle='--')
        plt.legend()
        plt.xlabel('Strain')
        plt.ylabel('Voronoi Volume')
        plt.show()
    return np.array(max_lst) < np.mean(mean_lst) * 2 
开发者ID:pyiron,项目名称:pyiron,代码行数:18,代码来源:interfacemethod.py

示例8: plot_efrontier

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_efrontier(self):
        """Plots the Efficient Frontier."""
        if self.efrontier is None:
            # compute efficient frontier first
            self.efficient_frontier()
        plt.plot(
            self.efrontier[:, 0],
            self.efrontier[:, 1],
            linestyle="-.",
            color="black",
            lw=2,
            label="Efficient Frontier",
        )
        plt.title("Efficient Frontier")
        plt.xlabel("Volatility")
        plt.ylabel("Expected Return")
        plt.legend() 
开发者ID:fmilthaler,项目名称:FinQuant,代码行数:19,代码来源:efficient_frontier.py

示例9: plot_pr

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_pr(auc_score, precision, recall, label=None, figure_path=None):
    """绘制R/P曲线"""
    try:
        from matplotlib import pylab
        pylab.figure(num=None, figsize=(6, 5))
        pylab.xlim([0.0, 1.0])
        pylab.ylim([0.0, 1.0])
        pylab.xlabel('Recall')
        pylab.ylabel('Precision')
        pylab.title('P/R (AUC=%0.2f) / %s' % (auc_score, label))
        pylab.fill_between(recall, precision, alpha=0.5)
        pylab.grid(True, linestyle='-', color='0.75')
        pylab.plot(recall, precision, lw=1)
        pylab.savefig(figure_path)
    except Exception as e:
        print("save image error with matplotlib")
        pass 
开发者ID:shibing624,项目名称:text-classifier,代码行数:19,代码来源:evaluate.py

示例10: plot_pr_curve

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_pr_curve(pr_curve_dml, pr_curve_base, title):
    """
      Function that plots the PR-curve.

      Args:
        pr_curve: the values of precision for each recall value
        title: the title of the plot
    """
    plt.figure(figsize=(16, 9))
    plt.plot(np.arange(0.0, 1.05, 0.05),
             pr_curve_base, color='r', marker='o', linewidth=3, markersize=10)
    plt.plot(np.arange(0.0, 1.05, 0.05),
             pr_curve_dml, color='b', marker='o', linewidth=3, markersize=10)
    plt.grid(True, linestyle='dotted')
    plt.xlabel('Recall', color='k', fontsize=27)
    plt.ylabel('Precision', color='k', fontsize=27)
    plt.yticks(color='k', fontsize=20)
    plt.xticks(color='k', fontsize=20)
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.0])
    plt.title(title, color='k', fontsize=27)
    plt.tight_layout()
    plt.show() 
开发者ID:MKLab-ITI,项目名称:ndvr-dml,代码行数:25,代码来源:utils.py

示例11: plotKChart

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plotKChart(self, misClassDict, saveFigPath):
        kList = []
        misRateList = []
        for k, misClassNum in misClassDict.iteritems():
            kList.append(k)
            misRateList.append(1.0 - 1.0/k*misClassNum)

        fig = plt.figure(saveFigPath)
        plt.plot(kList, misRateList, 'r--')
        plt.title(saveFigPath)
        plt.xlabel('k Num.')
        plt.ylabel('Misclassified Rate')
        plt.legend(saveFigPath)
        plt.grid(True)
        plt.savefig(saveFigPath)
        plt.show()

################################### PART3 TEST ########################################
# 例子 
开发者ID:ysh329,项目名称:statistical-learning-methods-note,代码行数:21,代码来源:kNN.py

示例12: plot_alignment_to_numpy

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_alignment_to_numpy(alignment, info=None):
    fig, ax = plt.subplots(figsize=(6, 4))
    im = ax.imshow(alignment, aspect='auto', origin='lower',
                   interpolation='none')
    fig.colorbar(im, ax=ax)
    xlabel = 'Decoder timestep'
    if info is not None:
        xlabel += '\n\n' + info
    plt.xlabel(xlabel)
    plt.ylabel('Encoder timestep')
    plt.tight_layout()

    fig.canvas.draw()
    data = save_figure_to_numpy(fig)
    plt.close()
    return data 
开发者ID:jxzhanggg,项目名称:nonparaSeq2seqVC_code,代码行数:18,代码来源:plotting_utils.py

示例13: addqqplotinfo

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [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

示例14: viz_missing_docwordfreq_stats

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def viz_missing_docwordfreq_stats(DocWordFreq_emp, DocWordFreq_model):
  from matplotlib import pylab
  DocWordFreq_missing = np.maximum(DocWordFreq_emp - DocWordFreq_model, 0)

  nnzEmp = count_num_nonzero(DocWordFreq_emp)
  nnzMiss = count_num_nonzero(DocWordFreq_missing)
  frac_nzMiss = nnzMiss / float(nnzEmp)

  nzMissPerDoc = np.sum(DocWordFreq_missing > 0, axis=1)
  CDF_nzMissPerDoc = np.sort(nzMissPerDoc)
  nzMissPerWord = np.sum(DocWordFreq_missing > 0, axis=0)
  CDF_nzMissPerWord = np.sort(nzMissPerWord)

  pylab.subplot(1,2,1)
  pylab.plot(CDF_nzMissPerDoc)
  pylab.ylabel('Num Nonzero Entries in Doc')
  pylab.xlabel('Document rank | frac= %.4f'% (frac_nzMiss))
  pylab.subplot(1,2,2)
  pylab.plot(CDF_nzMissPerWord)
  pylab.ylabel('Num Nonzero Entries per Word')
  pylab.xlabel('Word rank')

  pylab.show(block=True) 
开发者ID:daeilkim,项目名称:refinery,代码行数:25,代码来源:BirthMoveTopicModel.py

示例15: plot_performance_profiles

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylabel [as 别名]
def plot_performance_profiles(problems, solvers):
    """
    Plot performance profiles in matplotlib for specified problems and solvers
    """
    # Remove OSQP polish solver
    solvers = solvers.copy()
    for s in solvers:
        if "polish" in s:
            solvers.remove(s)

    df = pd.read_csv('./results/%s/performance_profiles.csv' % problems)
    plt.figure(0)
    for solver in solvers:
        plt.plot(df["tau"], df[solver], label=solver)
    plt.xlim(1., 10000.)
    plt.ylim(0., 1.)
    plt.xlabel(r'Performance ratio $\tau$')
    plt.ylabel('Ratio of problems solved')
    plt.xscale('log')
    plt.legend()
    plt.grid()
    plt.show(block=False)
    results_file = './results/%s/%s.png' % (problems, problems)
    print("Saving plots to %s" % results_file)
    plt.savefig(results_file) 
开发者ID:oxfordcontrol,项目名称:osqp_benchmarks,代码行数:27,代码来源:benchmark.py


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