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


Python cm.coolwarm方法代码示例

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


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

示例1: plot3d

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def plot3d(self, scale=0.32):
		r"""Plot 3d scatter plot of benchmark function.

		Args:
			scale (float): Scale factor for points.
		"""
		fig = plt.figure()
		ax = Axes3D(fig)
		func = self.function()
		Xr, Yr = arange(self.Lower, self.Upper, scale), arange(self.Lower, self.Upper, scale)
		X, Y = meshgrid(Xr, Yr)
		Z = vectorize(self.__2dfun)(X, Y, func)
		ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
		ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm)
		ax.set_xlabel('X')
		ax.set_ylabel('Y')
		ax.set_zlabel('Z')
		plt.show()

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 
开发者ID:NiaOrg,项目名称:NiaPy,代码行数:22,代码来源:benchmark.py

示例2: plotFranke

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def plotFranke():
    """
    Plots Franke's function
    """
    x = np.linspace(0, 1, num=1000)
    y = np.linspace(0, 1, num=1000)
    X, Y = np.meshgrid(x, y)
    Z = f(X, Y)

    fig = plt.figure()
    ax = fig.gca(projection='3d')

    surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
                           linewidth=0)
    fig.colorbar(surf, shrink=0.5, aspect=5)
    plt.show() 
开发者ID:josejimenezluna,项目名称:pyGPGO,代码行数:18,代码来源:franke.py

示例3: plotPred

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def plotPred(gpgo, num=100):
    X = np.linspace(0, 1, num=num)
    Y = np.linspace(0, 1, num=num)
    U = np.zeros((num**2, 2))
    i = 0
    for x in X:
        for y in Y:
            U[i, :] = [x, y]
            i += 1
    z = gpgo.GP.predict(U)[0]
    Z = z.reshape((num, num))
    X, Y = np.meshgrid(X, Y)
    ax = fig.add_subplot(1, 2, 2, projection='3d')
    ax.set_title('Gaussian Process surrogate')
    surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
                           linewidth=0)
    fig.colorbar(surf, shrink=0.5, aspect=5)
    best = gpgo.best
    ax.scatter([best[0]], [best[1]], s=40, marker='x', c='r', label='Sampled point')
    plt.legend(loc='lower right')
    #plt.show()
    return Z 
开发者ID:josejimenezluna,项目名称:pyGPGO,代码行数:24,代码来源:gif_gen.py

示例4: plot_surface

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def plot_surface(x,y,z):
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    surf = ax.plot_surface(x, y, z, cmap=cm.coolwarm,
                           linewidth=0, antialiased=False)

    # Customize the z axis.
    ax.zaxis.set_major_locator(LinearLocator(10))
    ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

    # Add a color bar which maps values to colors.
    fig.colorbar(surf, shrink=0.5, aspect=5)
    if save_info:
        fig.tight_layout()
        fig.savefig('./gaussian'+ str(idx) + '.png')
    plt.show() 
开发者ID:limingwu8,项目名称:Image-Restoration,代码行数:18,代码来源:deforme.py

示例5: three_d_grid

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def three_d_grid():
    fig = plt.figure()
    ax = fig.gca(projection='3d')

    # Make data.
    X = np.arange(-5, 5, 0.25)
    Y = np.arange(-5, 5, 0.25)
    X, Y = np.meshgrid(X, Y)
    R = (X**3 + Y**3)
    Z = R

    # Plot the surface.
    surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
                        linewidth=0, antialiased=False)

    # Customize the z axis.
    #ax.set_zlim(-1.01, 1.01)
    #ax.zaxis.set_major_locator(LinearLocator(10))
    #ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

    # Add a color bar which maps values to colors.
    fig.colorbar(surf, shrink=0.5, aspect=5)
    plt.show() 
开发者ID:ryu577,项目名称:pyray,代码行数:25,代码来源:lagrange.py

示例6: ThrShow

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def ThrShow(self,data):        
        font1 = {'family' : 'STXihei',
         'weight' : 'normal',
         'size'   : 50,
         }
        fig, ax = plt.subplots(subplot_kw=dict(projection='3d'),figsize=(50,20))
        ls = LightSource(data.shape[0], data.shape[1])
        rgb = ls.shade(data, cmap=cm.gist_earth, vert_exag=0.1, blend_mode='soft')
        x=np.array([list(range(data.shape[0]))]*data.shape[1])
        print(x.shape,x.T.shape,data.shape)
        surf = ax.plot_surface(x, x.T, data, rstride=1, cstride=1, facecolors=rgb,linewidth=0, antialiased=False, shade=False,alpha=0.3)
        fig.colorbar(surf,shrink=0.5,aspect=5)
        cset = ax.contour(x, x.T, data, zdir='z', offset=37, cmap=cm.coolwarm)
        cset = ax.contour(x, x.T, data, zdir='x', offset=-30, cmap=cm.coolwarm)
        cset = ax.contour(x, x.T, data, zdir='y', offset=-30, cmap=cm.coolwarm)
        plt.show() 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:18,代码来源:LST.py

示例7: update

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def update(self,data):
    self.txt.set_text(self.text%data[self.label])
    self.dot.set_color(cm.coolwarm((data[self.label]-self.low)/self.amp)) 
开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:5,代码来源:drawing.py

示例8: prepare

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def prepare(self):
    plt.switch_backend(self.backend)
    self.fig, self.ax = plt.subplots(figsize=self.window_size)
    image = self.ax.imshow(plt.imread(self.image), cmap=cm.coolwarm)
    image.set_clim(-0.5, 1)
    cbar = self.fig.colorbar(image, ticks=[-0.5, 1], fraction=0.061,
        orientation='horizontal', pad=0.04)
    cbar.set_label('Temperatures(C)')
    cbar.ax.set_xticklabels(self.crange)
    self.ax.set_title(self.title)
    self.ax.set_axis_off()

    self.elements = []
    for d in self.draw:
      self.elements.append(elements[d['type']](self,**d)) 
开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:17,代码来源:drawing.py

示例9: plotFranke

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def plotFranke():
    x = np.linspace(0, 1, num=1000)
    y = np.linspace(0, 1, num=1000)
    X, Y = np.meshgrid(x, y)
    Z = f(X, Y)
    ax = fig.add_subplot(1, 2, 1, projection='3d')
    ax.set_title('Original function')

    surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
                           linewidth=0)
    fig.colorbar(surf, shrink=0.5, aspect=5) 
开发者ID:josejimenezluna,项目名称:pyGPGO,代码行数:13,代码来源:gif_gen.py

示例10: plot_cost_3D

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def plot_cost_3D(x, y, costfunc, mb_history=None):
    """Plot cost as 3D and contour.

    x, y: arrays of data.
    costfunc: cost function with signature like compute_cost.
    mb_history:
        if provided, it's a sequence of (m, b) pairs that are added as
        crosshairs markers on top of the contour plot.
    """
    lim = 10.0
    N = 250
    ms = np.linspace(-lim, lim, N)
    bs = np.linspace(-lim, lim, N)
    cost = np.zeros((N, N))
    for m_idx in range(N):
        for b_idx in range(N):
            cost[m_idx, b_idx] = costfunc(x, y, ms[m_idx], bs[b_idx])
    # Configure 3D plot.
    fig = plt.figure()
    fig.set_tight_layout(True)
    ax1 = fig.add_subplot(1, 2, 1, projection='3d')
    ax1.set_xlabel('b')
    ax1.set_ylabel('m')
    msgrid, bsgrid = np.meshgrid(ms, bs)
    surf = ax1.plot_surface(msgrid, bsgrid, cost, cmap=cm.coolwarm)

    # Configure contour plot.
    ax2 = fig.add_subplot(1, 2, 2)
    ax2.contour(msgrid, bsgrid, cost)
    ax2.set_xlabel('b')
    ax2.set_ylabel('m')

    if mb_history:
        ms, bs = zip(*mb_history)
        plt.plot(bs, ms, 'rx', mew=3, ms=5)

    plt.show() 
开发者ID:eliben,项目名称:deep-learning-samples,代码行数:39,代码来源:simple_linear_regression.py

示例11: post_step

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def post_step(self, status):
        """
        Overwrite standard dump per step

        Args:
            status: status object per step
        """
        super(plot_solution,self).post_step(status)

        #yplot = self.level.uend.values
        #xx    = self.level.prob.xx
        #zz    = self.level.prob.zz
        #self.fig.clear()
        #plt.plot( xx[:,0], yplot[2,:,0])
        #plt.ylim([-1.1, 1.1])
        #plt.show(block=False)
        #plt.pause(0.00001)        
          
        if True:
          yplot = self.level.uend.values
          xx    = self.level.prob.xx
          zz    = self.level.prob.zz
          self.fig.clear()
          CS = plt.contourf(xx, zz, yplot[2,:,:], rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False)
          cbar = plt.colorbar(CS)
          plt.axes().set_xlim(xmin = self.level.prob.x_bounds[0], xmax = self.level.prob.x_bounds[1])
          plt.axes().set_ylim(ymin = self.level.prob.z_bounds[0], ymax = self.level.prob.z_bounds[1])
          plt.axes().set_aspect('equal')
          plt.xlabel('x')
          plt.ylabel('z')
          #plt.tight_layout()
          plt.show(block=False)
          plt.pause(0.00001)

        return None 
开发者ID:Parallel-in-Time,项目名称:pySDC,代码行数:37,代码来源:HookClass.py

示例12: post_step

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def post_step(self, status):
        """
        Overwrite standard dump per step

        Args:
            status: status object per step
        """
        super(plot_solution,self).post_step(status)

        if False:
          yplot = self.level.uend.values
          xx    = self.level.prob.xc
          yy    = self.level.prob.yc
          self.fig.clear()
          plt.plot( xx[:,0], yplot[0,:,0])
          plt.ylim([-1.0, 1.0])
          plt.show(block=False)
          plt.pause(0.00001)        

            
        if True:
          yplot = self.level.uend.values
          xx    = self.level.prob.xc
          zz    = self.level.prob.yc
          self.fig.clear()
          CS = plt.contourf(xx, zz, yplot[0,:,:], rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False)
          cbar = plt.colorbar(CS)
          #plt.axes().set_xlim(xmin = self.level.prob.x_b[0], xmax = self.level.prob.x_b[1])
          #plt.axes().set_ylim(ymin = self.level.prob.z_b[0], ymax = self.level.prob.z_b[1])
          #plt.axes().set_aspect('equal')
          plt.xlabel('x')
          plt.ylabel('z')
          #plt.tight_layout()
          plt.show(block=False)
          plt.pause(0.00001)

        return None 
开发者ID:Parallel-in-Time,项目名称:pySDC,代码行数:39,代码来源:HookClass.py

示例13: plot_3d

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def plot_3d(X,Y,Z, titleStr):
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
        linewidth=0, antialiased=False)
    fig.colorbar(surf, shrink=0.5, aspect=5)
    plt.xlabel('U1')
    plt.ylabel('U2')
    plt.title(titleStr)
    plt.show() 
开发者ID:stochasticresearch,项目名称:copula-py,代码行数:12,代码来源:plot_utils.py

示例14: plot_NOM_3D

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def plot_NOM_3D(fname):
    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib import cm
    from matplotlib.ticker import LinearLocator, FormatStrFormatter

    xL, yL, zL = np.loadtxt(fname+'.dat', unpack=True)
    nX = (yL == yL[0]).sum()
    nY = (xL == xL[0]).sum()
    x = xL.reshape((nY, nX))
    y = yL.reshape((nY, nX))
    z = zL.reshape((nY, nX))
    x1D = xL[:nX]
    y1D = yL[::nX]
#    z += z[::-1, :]
    zmax = abs(z).max()

    fig = plt.figure()
    ax = fig.gca(projection='3d')
    surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap=cm.coolwarm,
                           linewidth=0, antialiased=False, alpha=0.5)
    ax.set_zlim(-zmax, zmax)
    ax.zaxis.set_major_locator(LinearLocator(10))
    ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

    fig.colorbar(surf, shrink=0.5, aspect=5)

    splineZ = ndimage.spline_filter(z.T)
    nrays = 1e3
    xnew = np.random.uniform(x1D[0], x1D[-1], nrays)
    ynew = np.random.uniform(y1D[0], y1D[-1], nrays)
    coords = np.array([(xnew-x1D[0]) / (x1D[-1]-x1D[0]) * (nX-1),
                       (ynew-y1D[0]) / (y1D[-1]-y1D[0]) * (nY-1)])
    znew = ndimage.map_coordinates(splineZ, coords, prefilter=True)
    ax.scatter(xnew, ynew, znew, c=znew, marker='o', color='gray', s=50,
               cmap=cm.coolwarm)

    fig.savefig(fname+'_3d.png')
    plt.show() 
开发者ID:kklmn,项目名称:xrt,代码行数:40,代码来源:read_NOM_maps.py

示例15: createHoffmueller

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import coolwarm [as 别名]
def createHoffmueller(data, coordSeries, timeSeries, coordName, title, interpolate='nearest'):

    cmap = cm.coolwarm
    # ls = LightSource(315, 45)
    # rgb = ls.shade(data, cmap)

    fig, ax = plt.subplots()
    fig.set_size_inches(11.0, 8.5)
    cax = ax.imshow(data, interpolation=interpolate, cmap=cmap)

    def yFormatter(y, pos):
        if y < len(coordSeries):
            return "%s $^\circ$" % (int(coordSeries[int(y)] * 100.0) / 100.)
        else:
            return ""

    def xFormatter(x, pos):
        if x < len(timeSeries):
            return timeSeries[int(x)].strftime('%b %Y')
        else:
            return ""

    ax.xaxis.set_major_formatter(FuncFormatter(xFormatter))
    ax.yaxis.set_major_formatter(FuncFormatter(yFormatter))

    ax.set_title(title)
    ax.set_ylabel(coordName)
    ax.set_xlabel('Date')

    fig.colorbar(cax)
    fig.autofmt_xdate()

    plt.show() 
开发者ID:apache,项目名称:incubator-sdap-nexus,代码行数:35,代码来源:lat_hof_moeller.py


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