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


Python mlab.bivariate_normal函数代码示例

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


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

示例1: function

def function(position):
  xg = 3.0 * position[0]
  yg = 3.0 * position[1]
  h1 = bivariate_normal(xg, yg, 1.0, 1.0, 0.0, 0.0)
  h2 = bivariate_normal(xg, yg, 1.5, 0.5, 1, 1)
  h = 10.0 * (h1 - h2)
  return h
开发者ID:FluidityProject,项目名称:fluidity,代码行数:7,代码来源:height.py

示例2: calcAtomGaussians

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:ashwin,项目名称:rdkit,代码行数:28,代码来源:__init__.py

示例3: main

def main(args):
    x = np.arange(-3.0, 3.0, 0.025)
    y = np.arange(-3.0, 3.0, 0.025)
    X, Y = np.meshgrid(x, y)
    Z0 = mlab.bivariate_normal(X, Y, 1.0, 4.0, 0.0, 0.0)
    Z1 = mlab.bivariate_normal(X, Y, 4.0, 1.0, 0.0, 0.0)
    Z = Z1 - Z0

    cdict = {
        "red": ((0.0, 0.0, 0.98), (1.0, 1.0, 1.0)),
        "green": ((0.0, 0.0, 0.74), (1.0, 1.0, 1.0)),
        "blue": ((0.0, 0.0, 0.0), (1.0, 1.0, 1.0)),
    }
    _cmap = LinearSegmentedColormap("tmp", cdict)

    plt.imshow(Z >= 0, interpolation="nearest", cmap=_cmap, extent=(-3, 3, -3, 3))
    CS = plt.contour(Z, [0], colors="g", extent=(-3, 3, -3, 3))
    plt.clabel(CS, inline=1, manual=[(-2, 2), (2, 2)], fmt="boundaries")

    CS0 = plt.contour(X, Y, Z0, 4, colors="r")
    plt.clabel(CS0, inline=1, manual=[(0, 0)], fmt="p(x | y = 0)")
    plt.text(0, -2, "f(x) = 0")
    plt.text(0, 2, "f(x) = 0")

    CS1 = plt.contour(X, Y, Z1, 4, colors="b")
    plt.clabel(CS1, inline=1, manual=[(0, 0)], fmt="p(x | y = 1)")
    plt.text(-2, 0, "f(x) = 1")
    plt.text(2, 0, "f(x) = 1")

    plt.show()
开发者ID:misaka-10032,项目名称:ML,代码行数:30,代码来源:1-plot.py

示例4: heatmap_with_hexagon_cell

def heatmap_with_hexagon_cell(x,y,timestamp):
	from matplotlib import cm 
	from matplotlib import mlab as ml
	n = 1e5
	#x = y = NP.linspace(-5, 5, 100)
	X, Y = np.meshgrid(x, y)
	Z1 = ml.bivariate_normal(X, Y, 2, 2, 0, 0)
	Z2 = ml.bivariate_normal(X, Y, 4, 1, 1, 1)
	ZD = Z2 - Z1
	x = X.ravel()
	y = Y.ravel()
	z = ZD.ravel()
	gridsize=300
	plt.subplot(111)

	# if 'bins=None', then color of each hexagon corresponds directly to its count
	# 'C' is optional--it maps values to x-y coordinates; if 'C' is None (default) then 
	# the result is a pure 2D histogram 

	plt.hexbin(x, y, C=z, gridsize=gridsize, cmap=cm.jet, bins=None)
	plt.axis([x.min(), x.max(), y.min(), y.max()])
        plt.text(18.9300,72.8200,"ChurchGate",bbox=dict(facecolor='green', alpha=0.5))
        plt.text(19.1833,72.8333,"Malad",bbox=dict(facecolor='green', alpha=0.5))
        plt.text(19.0587,72.8997,"Chembur",bbox=dict(facecolor='green', alpha=0.5))
        plt.text(19.2045,72.8376,"Kandivili",bbox=dict(facecolor='green', alpha=0.5))

	cb = plt.colorbar()
	cb.set_label('mean value')
	plt.show() 
开发者ID:shashanksingh,项目名称:prediction_python,代码行数:29,代码来源:plot_heatmap.py

示例5: test_mask_image_over_under

def test_mask_image_over_under():
    delta = 0.025
    x = y = np.arange(-3.0, 3.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)
    Z = 10*(Z2 - Z1)  # difference of Gaussians

    palette = copy(plt.cm.gray)
    palette.set_over('r', 1.0)
    palette.set_under('g', 1.0)
    palette.set_bad('b', 1.0)
    Zm = ma.masked_where(Z > 1.2, Z)
    fig, (ax1, ax2) = plt.subplots(1, 2)
    im = ax1.imshow(Zm, interpolation='bilinear',
                    cmap=palette,
                    norm=colors.Normalize(vmin=-1.0, vmax=1.0, clip=False),
                    origin='lower', extent=[-3, 3, -3, 3])
    ax1.set_title('Green=low, Red=high, Blue=bad')
    fig.colorbar(im, extend='both', orientation='horizontal',
                 ax=ax1, aspect=10)

    im = ax2.imshow(Zm, interpolation='nearest',
                    cmap=palette,
                    norm=colors.BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1],
                                             ncolors=256, clip=False),
                    origin='lower', extent=[-3, 3, -3, 3])
    ax2.set_title('With BoundaryNorm')
    fig.colorbar(im, extend='both', spacing='proportional',
                 orientation='horizontal', ax=ax2, aspect=10)
开发者ID:4over7,项目名称:matplotlib,代码行数:30,代码来源:test_image.py

示例6: get_image

def get_image():
    delta = 0.25
    x = y = np.arange(-3.0, 3.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)
    Z = Z2 - Z1  # difference of Gaussians
    return Z
开发者ID:AlexandreAbraham,项目名称:matplotlib,代码行数:8,代码来源:affine_image.py

示例7: get_gauss_kernel

def get_gauss_kernel(sigma, size, res):
    """
    return a two dimesional gausian kernel of shape (size*(1/resolution),size*(1/resolution))
    with a std deviation of std
    """
    x,y = ny.mgrid[-size/2:size/2:res,-size/2:size/2:res]
    b=bivariate_normal(x,y,sigma,sigma)
    A=(1/ny.max(b))
    #A=1
    return x,y,A*bivariate_normal(x, y, sigma, sigma)
开发者ID:ohaas,项目名称:cmn,代码行数:10,代码来源:model.py

示例8: __call__

    def __call__(self, inputs):
        from matplotlib.mlab import bivariate_normal
        X = self.get_input('X')
        Y = self.get_input('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)
        # difference of Gaussians
        Z = 10.0 * (Z2 - Z1)

        return Z
开发者ID:MarieLatutu,项目名称:openalea-components,代码行数:10,代码来源:py_pylab.py

示例9: create_plot

def create_plot():
    x = np.linspace(-3.0, 3.0, 30)
    y = np.linspace(-2.0, 2.0, 30)
    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)
    Z = 10.0 * (Z2 - Z1)

    fig, ax = plt.subplots()
    CS = ax.contourf(X, Y, Z, 30)
    return fig
开发者ID:Bantalik,项目名称:mpld3,代码行数:11,代码来源:test_contourf.py

示例10: test_image_plot

    def test_image_plot(self):
        delta = 0.025
        x = y = np.arange(-3.0, 3.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)
        Z = Z2 - Z1  # difference of Gaussians

        im = plt.imshow(Z, interpolation='bilinear', cmap=cm.RdYlGn,
                        origin='lower', extent=[-3, 3, -3, 3],
                        vmax=abs(Z).max(), vmin=-abs(Z).max())
        plt.show()
开发者ID:rosswhitfield,项目名称:mantid,代码行数:12,代码来源:MantidPlotMatplotlibTest.py

示例11: test3

def test3():
    N = 1000
    x = (np.linspace(-2.0, 3.0, N))
    y = (np.linspace(-2.0, 2.0, N))

    X, Y = np.meshgrid(x, y)
    X1 = 0.5*(X[:-1,:-1] + X[1:,1:])
    Y1 = 0.5*(Y[:-1,:-1] + Y[1:,1:])

    from matplotlib.mlab import bivariate_normal
    Z1 = bivariate_normal(X1, Y1, 0.1, 0.2, 1.27, 1.11) + 100.*bivariate_normal(X1, Y1, 1.0, 1.0, 0.23, 0.72)


    Z1[Z1>0.9*np.max(Z1)] = +np.inf

    cdict = {'red':   [(0.0,  1.0, 1.0),
                       (1.0,  1.0, 1.0)],

             'green': [(0.0,  0.0, 0.0),
                       (1.0,  0.0, 0.0)],

             'blue':  [(0.0,  0.0, 0.0),
                       (1.0,  0.0, 0.0)],

             'alpha': [(0.0,  0.0, 0.0),
                       (1.0,  1.0, 1.0)],
             }

    # this is a color maps showing how the resukt should look like
    cdictx = {'red':   [(0.0,  1.0, 1.0),
                       (1.0,  1.0, 1.0)],

             'green': [(0.0,  1.0, 1.0),
                       (1.0,  0.0, 0.0)],

             'blue':  [(0.0,  1.0, 1.0),
                       (1.0,  0.0, 0.0)],

             }

    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    col = mpl_colors.LinearSegmentedColormap('test', cdict)
    i = ax.pcolorfast(x, y, Z1, cmap = col)
    plt.colorbar(i)

    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    col = mpl_colors.LinearSegmentedColormap('testx', cdictx)
    i = ax.pcolorfast(x, y, Z1, cmap = col)
    plt.colorbar(i)

    plt.show()
开发者ID:earnric,项目名称:modules,代码行数:53,代码来源:test.py

示例12: testcontour

    def testcontour(self):
        #contour plot test data:
        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)

        plt.contour(X, Y, Z, 20)
开发者ID:QBI-Software,项目名称:Tracking,代码行数:12,代码来源:test_plot.py

示例13: main

def main():
    x = np.linspace(-3.0, 3.0, 30)
    y = np.linspace(-2.0, 2.0, 30)
    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)
    Z = 10.0 * (Z2 - Z1)

    fig, ax = plt.subplots()
    CS = ax.contour(X, Y, Z)
    ax.clabel(CS, inline=True, fontsize=10)
    return fig
开发者ID:Ahmed,项目名称:mpld3,代码行数:12,代码来源:test_contour.py

示例14: calcAtomGaussians

def calcAtomGaussians(mol,a=0.03,step=0.02,weights=None):
  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:nclopezo,项目名称:chembl_beaker,代码行数:13,代码来源:__init__.py

示例15: get_test_data

def get_test_data(delta=0.05):
    from matplotlib.mlab import meshgrid, bivariate_normal
    x = y = npy.arange(-3.0, 3.0, delta)
    X, Y = 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
开发者ID:mcvine,项目名称:sansmodels,代码行数:13,代码来源:test3d.py


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