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


Python mlab.bivariate_normal方法代码示例

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


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

示例1: test_contour_xyz

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def test_contour_xyz(self):
        _skip_if_no_matplotlib()
        import numpy as np
        import matplotlib.mlab as mlab

        delta = 0.025
        x = np.arange(-3.0, 3.0, delta)
        y = np.arange(-2.0, 2.0, delta)
        X, Y = np.meshgrid(x, y)
        Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
        Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
        # difference of Gaussians
        Z = 10.0 * (Z2 - Z1)

        viewer = cesiumpy.Viewer()
        viewer.plot.contour(X, Y, Z)
        self.assertEqual(len(viewer.entities), 7)
        self.assertTrue(all(isinstance(x, cesiumpy.Polyline)
                            for x in viewer.entities))
        self.assertEqual(viewer.entities[0].material,
                         cesiumpy.color.Color(0.0, 0.0, 0.5, 1.0)) 
开发者ID:sinhrks,项目名称:cesiumpy,代码行数:23,代码来源:test_plotting.py

示例2: get_test_data

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def get_test_data(delta=0.05):
    '''
    Return a tuple X, Y, Z with a test data set.
    '''

    from matplotlib.mlab import  bivariate_normal
    x = y = np.arange(-3.0, 3.0, delta)
    X, Y = np.meshgrid(x, y)

    Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
    Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
    Z = Z2 - Z1

    X = X * 10
    Y = Y * 10
    Z = Z * 500
    return X, Y, Z



########################################################
# Register Axes3D as a 'projection' object available
# for use just like any other axes
######################################################## 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:axes3d.py

示例3: test_labels

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def test_labels():
    # Adapted from pylab_examples example code: contour_demo.py
    # see issues #2475, #2843, and #2818 for explanation
    delta = 0.025
    x = np.arange(-3.0, 3.0, delta)
    y = np.arange(-2.0, 2.0, delta)
    X, Y = np.meshgrid(x, y)
    Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
    Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
    # difference of Gaussians
    Z = 10.0 * (Z2 - Z1)

    fig, ax = plt.subplots(1, 1)
    CS = ax.contour(X, Y, Z)
    disp_units = [(216, 177), (359, 290), (521, 406)]
    data_units = [(-2, .5), (0, -1.5), (2.8, 1)]

    CS.clabel()

    for x, y in data_units:
        CS.add_label_near(x, y, inline=True, transform=None)

    for x, y in disp_units:
        CS.add_label_near(x, y, inline=True, transform=False) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:26,代码来源:test_contour.py

示例4: gauss_params_plot

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def gauss_params_plot(strokes, title ='Distribution of Gaussian Mixture parameters', figsize = (20,2)):
    plt.figure(figsize=figsize)
    import matplotlib.mlab as mlab
    buff = 1 ; epsilon = 1e-4
    minx, maxx = np.min(strokes[:,0])-buff, np.max(strokes[:,0])+buff
    miny, maxy = np.min(strokes[:,1])-buff, np.max(strokes[:,1])+buff
    delta = abs(maxx-minx)/400. ;
    
    x = np.arange(minx, maxx, delta)
    y = np.arange(miny, maxy, delta)
    X, Y = np.meshgrid(x, y)
    Z = np.zeros_like(X)
    for i in range(strokes.shape[0]):
        gauss = mlab.bivariate_normal(X, Y, mux=strokes[i,0], muy=strokes[i,1], \
            sigmax=strokes[i,2], sigmay=strokes[i,3], sigmaxy=0) # sigmaxy=strokes[i,4] gives error
        Z += gauss * np.power(strokes[i,3] + strokes[i,2], .4) / (np.max(gauss) + epsilon)
    
    plt.title(title, fontsize=20)
    plt.imshow(np.flipud(Z), cmap=cm.gnuplot) 
开发者ID:GauravBh1010tt,项目名称:DL-Seq2Seq,代码行数:21,代码来源:eval_hand.py

示例5: calcAtomGaussians

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def calcAtomGaussians(mol, a=0.03, step=0.02, weights=None):
    """
  useful things to do with these:
  fig.axes[0].imshow(z,cmap=cm.gray,interpolation='bilinear',origin='lower',extent=(0,1,0,1))
  fig.axes[0].contour(x,y,z,20,colors='k')

  fig=Draw.MolToMPL(m);
  contribs=Crippen.rdMolDescriptors._CalcCrippenContribs(m)
  logps,mrs=zip(*contribs)
  x,y,z=Draw.calcAtomGaussians(m,0.03,step=0.01,weights=logps)
  fig.axes[0].imshow(z,cmap=cm.jet,interpolation='bilinear',origin='lower',extent=(0,1,0,1))
  fig.axes[0].contour(x,y,z,20,colors='k',alpha=0.5)
  fig.savefig('coumlogps.colored.png',bbox_inches='tight')


    """
    import numpy
    from matplotlib import mlab
    x = numpy.arange(0, 1, step)
    y = numpy.arange(0, 1, step)
    X, Y = numpy.meshgrid(x, y)
    if weights is None:
        weights = [1.] * mol.GetNumAtoms()
    Z = mlab.bivariate_normal(X, Y, a, a, mol._atomPs[0][0], mol._atomPs[0][1]) * weights[0]
    for i in range(1, mol.GetNumAtoms()):
        Zp = mlab.bivariate_normal(X, Y, a, a, mol._atomPs[i][0], mol._atomPs[i][1])
        Z += Zp * weights[i]
    return X, Y, Z 
开发者ID:blackmints,项目名称:3DGCN,代码行数:30,代码来源:__init__.py

示例6: image_demo

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def image_demo(fig, ax):
    delta = 0.025
    x = y = np.arange(-3.0, 3.0, delta)
    xx, yy = np.meshgrid(x, y)
    z1 = mlab.bivariate_normal(xx, yy, 1.0, 1.0, 0.0, 0.0)
    z2 = mlab.bivariate_normal(xx, yy, 1.5, 0.5, 1, 1)
    image = z2-z1  # Difference of Gaussians
    img_plot = ax.imshow(image)
    ax.set_title('image')

    fig.tight_layout()
    # `colorbar` should be called after `tight_layout`.
    fig.colorbar(img_plot, ax=ax) 
开发者ID:tonysyu,项目名称:matplotlib-style-gallery,代码行数:15,代码来源:artist-demo.py

示例7: gen_gaussian_plot_vals

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def gen_gaussian_plot_vals(μ, C):
    "Z values for plotting the bivariate Gaussian N(μ, C)"
    m_x, m_y = float(μ[0]), float(μ[1])
    s_x, s_y = np.sqrt(C[0, 0]), np.sqrt(C[1, 1])
    s_xy = C[0, 1]
    return bivariate_normal(X, Y, s_x, s_y, m_x, m_y, s_xy) 
开发者ID:QuantEcon,项目名称:QuantEcon.lectures.code,代码行数:8,代码来源:gaussian_contours.py

示例8: main

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def main():
    # Part of the example at 
    # http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/contour_demo.py
    delta = 0.025
    x = numpy.arange(-3.0, 3.0, delta)
    y = numpy.arange(-2.0, 2.0, delta)
    X, Y = numpy.meshgrid(x, y)
    Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
    Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
    Z = 10.0 * (Z2 - Z1)
    pyplot.figure()
    CS = pyplot.contour(X, Y, Z)
    pyplot.show() 
开发者ID:Lithium876,项目名称:ConTroll_Remote_Access_Trojan,代码行数:15,代码来源:test_matplotlib.py

示例9: plot_contours

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import bivariate_normal [as 别名]
def plot_contours(data, means, covs, title):
    plt.figure()
    plt.plot([x[0] for x in data], [y[1] for y in data],'ko') # data

    delta = 0.025
    k = len(means)
    x = np.arange(-2.0, 7.0, delta)
    y = np.arange(-2.0, 7.0, delta)
    X, Y = np.meshgrid(x, y)
    col = ['green', 'red', 'indigo']
    for i in range(k):
        mean = means[i]
        cov = covs[i]
        sigmax = np.sqrt(cov[0][0])
        sigmay = np.sqrt(cov[1][1])
        sigmaxy = cov[0][1]/(sigmax*sigmay)
        Z = mlab.bivariate_normal(X, Y, sigmax, sigmay, mean[0], mean[1], sigmaxy)
        plt.contour(X, Y, Z, colors = col[i])
        plt.title(title)
    plt.rcParams.update({'font.size':16})
    plt.tight_layout()


# In[26]:

# Parameters after initialization 
开发者ID:SSQ,项目名称:Coursera-UW-Machine-Learning-Clustering-Retrieval,代码行数:28,代码来源:3_em-for-gmm.py


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