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


Python pyplot.tricontour函数代码示例

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


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

示例1: plot

 def plot(self, N=6, cm=plt.cm.jet):
     plt.figure()
     plt.gca().set_aspect('equal')
     plt.tricontourf(self.triang, self.density, N, cm=cm)
     plt.colorbar()
     plt.tricontour(self.triang, self.density, N, colors='k')
     plt.show()
开发者ID:stenotech,项目名称:apsg,代码行数:7,代码来源:plotting.py

示例2: my_plot

def my_plot(u,v,t,daystr,levels):
    #boston light swim
    ax= [-71.10, -70.10, 41.70, 42.70] # region to plot
    vel_arrow = 0.2 # velocity arrow scale
    subsample = 8  # subsampling of velocity vectors

    # find velocity points in bounding box
    ind = np.argwhere((lonc >= ax[0]) & (lonc <= ax[1]) & (latc >= ax[2]) & (latc <= ax[3]))

    np.random.shuffle(ind)
    Nvec = int(len(ind) / subsample)
    idv = ind[:Nvec]
    # tricontourf plot of water depth with vectors on top
    plt.figure(figsize=(20,10))
    plt.subplot(111,aspect=(1.0/np.cos(lat[:].mean()*np.pi/180.0)))
    #tricontourf(tri, t,levels=levels,shading='faceted',cmap=plt.cm.gist_earth)
    plt.tricontourf(tri, t,levels=levels,shading='faceted')
    plt.axis(ax)
    plt.gca().patch.set_facecolor('0.5')
    cbar=plt.colorbar()
    cbar.set_label('Forecast Surface Temperature (C)', rotation=-90)
    plt.tricontour(tri, t,levels=[0])
    Q = plt.quiver(lonc[idv],latc[idv],u[idv],v[idv],scale=10)
    maxstr='%3.1f m/s' % vel_arrow
    qk = plt.quiverkey(Q,0.92,0.08,vel_arrow,maxstr,labelpos='W')
    plt.title('NECOFS Surface Velocity, Layer %d, %s UTC' % (ilayer, daystr))
    plt.plot(lon_track,lat_track,'m-o')
    plt.plot(lon_buoy,lat_buoy,'y-o')
开发者ID:rsignell-usgs,项目名称:notebook,代码行数:28,代码来源:Function.py

示例3: plot

def plot(filename):
    import os
    from matplotlib.pyplot import clf, tricontour, tricontourf, \
        gca, savefig, rc, minorticks_on

    if not os.path.exists(filename):
        return -1

    rc('text', usetex=True)
    clf()
    x, y, tri, ux, uy = load_velocity(filename)
    tricontourf(x, y, tri, ux, 16)
    tricontour(x, y, tri, ux, 16, linestyles='-',
               colors='black', linewidths=0.5)
    minorticks_on()
    gca().set_aspect('equal')
    gca().tick_params(direction='out', which='both')
    gca().set_xticklabels([])
    gca().set_yticklabels([])

    name, _ = os.path.splitext(filename)
    name = os.path.basename(name)

    savefig('{0}.png'.format(name), dpi=300, bbox_inches='tight')
    savefig('{0}.pdf'.format(name), bbox_inches='tight')
开发者ID:mrklein,项目名称:vtk-plot,代码行数:25,代码来源:plot-vtk.py

示例4: test_tri_smooth_gradient

def test_tri_smooth_gradient():
    # Image comparison based on example trigradient_demo.

    def dipole_potential(x, y):
        """ An electric dipole potential V """
        r_sq = x ** 2 + y ** 2
        theta = np.arctan2(y, x)
        z = np.cos(theta) / r_sq
        return (np.max(z) - z) / (np.max(z) - np.min(z))

    # Creating a Triangulation
    n_angles = 30
    n_radii = 10
    min_radius = 0.2
    radii = np.linspace(min_radius, 0.95, n_radii)
    angles = np.linspace(0, 2 * np.pi, n_angles, endpoint=False)
    angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1)
    angles[:, 1::2] += np.pi / n_angles
    x = (radii * np.cos(angles)).flatten()
    y = (radii * np.sin(angles)).flatten()
    V = dipole_potential(x, y)
    triang = mtri.Triangulation(x, y)
    xmid = x[triang.triangles].mean(axis=1)
    ymid = y[triang.triangles].mean(axis=1)
    mask = np.where(xmid * xmid + ymid * ymid < min_radius * min_radius, 1, 0)
    triang.set_mask(mask)

    # Refine data - interpolates the electrical potential V
    refiner = mtri.UniformTriRefiner(triang)
    tri_refi, z_test_refi = refiner.refine_field(V, subdiv=3)

    # Computes the electrical field (Ex, Ey) as gradient of -V
    tci = mtri.CubicTriInterpolator(triang, -V)
    (Ex, Ey) = tci.gradient(triang.x, triang.y)
    E_norm = np.sqrt(Ex ** 2 + Ey ** 2)

    # Plot the triangulation, the potential iso-contours and the vector field
    plt.figure()
    plt.gca().set_aspect("equal")
    plt.triplot(triang, color="0.8")

    levels = np.arange(0.0, 1.0, 0.01)
    cmap = cm.get_cmap(name="hot", lut=None)
    plt.tricontour(tri_refi, z_test_refi, levels=levels, cmap=cmap, linewidths=[2.0, 1.0, 1.0, 1.0])
    # Plots direction of the electrical vector field
    plt.quiver(
        triang.x,
        triang.y,
        Ex / E_norm,
        Ey / E_norm,
        units="xy",
        scale=10.0,
        zorder=3,
        color="blue",
        width=0.007,
        headwidth=3.0,
        headlength=4.0,
    )
开发者ID:tonysyu,项目名称:matplotlib,代码行数:58,代码来源:test_triangulation.py

示例5: _add_LR_contour

def _add_LR_contour(x,y,color,label,columns,data,theta_star,threshold):
    ax = plt.gca()
    xvar, yvar, loc = _get_variables(ax,columns)
    
    X, Y, Z = _get_data_slice(xvar,yvar,columns,data,theta_star)
    
    triang = tri.Triangulation(X, Y)
    
    plt.tricontour(triang,Z,[threshold], colors='r')
开发者ID:Pyomo,项目名称:pyomo,代码行数:9,代码来源:graphics.py

示例6: contour

def contour(*arguments, **kwargs):
    """Call signatures::

    contour(X, Y, C, N, **kwargs)
    contour(X, Y, C, V, **kwargs)
    
    Create a contour plot of a 2-D llc array (with tricontour).
    
    *C* is the array of color values.

    *N* is the number of levels

    *V* is a list of levels
    
    *X* and *Y*, specify the (*x*, *y*) coordinates of
    the grid points

    **kwargs are passed to tricontour.
    
    """

    arglen = len(arguments)
    h = []
    if arglen >= 3:
        data = arguments[2].flatten()
        x = arguments[0].flatten()
        y = arguments[1].flatten()

        # Create the Triangulation; 
        # no triangles so Delaunay triangulation created. 
        triang = tri.Triangulation(x, y)
        ntri = triang.triangles.shape[0]

        # Mask off unwanted triangles.
        mask = np.where(data[triang.triangles].prod(axis=1)==0., 1, 0)
        triang.set_mask(mask)
                        
        if arglen == 3:
            h = plt.tricontour(triang, data, **kwargs)
        elif arglen == 4:
            h = plt.tricontour(triang, data, arguments[3], **kwargs)
        else:
            print("wrong number of arguments")
            print("need at least 3 or 4 arguments")
            sys.exit(__doc__)
        
        # show the triangles for debugging
        #plt.triplot(triang, color='0.7')

    else:
        print("wrong number of arguments")
        print("need at least x,y,fld")
        sys.exit(__doc__)

    return h
开发者ID:christophernhill,项目名称:MITgcm66h,代码行数:55,代码来源:llc.py

示例7: plotResult

 def plotResult(self, **k):
     x = []
     y = []
     z = []
     for n in self.nodes:
         x.append(n.x)
         y.append(n.y)
         z.append(k['r'][n.i-1])
     t = tri.Triangulation(x, y)
     plt.tricontour(t, z, 15, linewidths=0.5)
     #plt.tricontourf(t, z, 15, cmap=plt.cm.rainbow)
     plt.colorbar()
     #plt.plot(x, y, 'ko', ms=3)
     
开发者ID:kewitz,项目名称:mestrado,代码行数:13,代码来源:FEM2.py

示例8: stab_plot

 def stab_plot(self):
     x = self.x
     y = self.y
     z = self.z
     # initialize the delauney triangulation:
     triang = tri.Triangulation(x, y)
     # do the plots:
     plt.tricontourf(triang, z, colors=self.color, alpha=0.3, levels=[1.0, 2.0])
     plt.tricontour(triang, z, colors=self.color, levels=[1.0, 2.0])
     # title of the plot
     plt.title("Stability of " + self.model_name, fontsize=16)
     # labels
     plt.xlabel(self.param_names[0], fontsize=18)
     plt.ylabel(self.param_names[1], fontsize=18)
开发者ID:CosmicFish,项目名称:CosmicFish,代码行数:14,代码来源:plot_stability_space.py

示例9: contour

def contour(data, x, y, label=None, log=False):

    tri=Triangulation(x,y)

    plt.close('all')
    plt.figure()
    ax=plt.subplot(111)
    ax.minorticks_on()
    if(log):
        ax.set_xscale("log",nonposx='clip')
        ax.set_yscale("log",nonposy='clip')

    ax.set_xlim([min(x.min(),y.min()),max(x.max(),y.max())])
    ax.set_ylim([min(x.min(),y.min()),max(x.max(),y.max())])
    plt.xlabel('r [AU]')
    plt.ylabel('z [AU]')

    nmax=data.max()
    nmin=data.min()
    levels=np.logspace(np.log10(nmin),np.log10(nmax),num=12)

    plt.tricontourf(tri, data, levels, norm=colors.LogNorm(vmin=nmin, vmax=nmax))
    cbar=plt.colorbar(format='%.2e')
    cbar.set_label(label)

    CS=plt.tricontour(tri, data, levels, colors='black', linewidths=1.5)
    plt.clabel(CS, fontsize=8, inline=1)
    cbar.add_lines(CS)

    plt.triplot(tri, color='black', alpha=0.2)

    plt.show(block=False)
开发者ID:christianbrinch,项目名称:pythonToolkit,代码行数:32,代码来源:plots.py

示例10: contour_paths

 def contour_paths(self, epsilon):
     '''Extract the polygon patches for the provided epsilon'''
     figure = pyplot.figure()
     contours = pyplot.tricontour(self.triang, self.vals, levels=[epsilon])
     paths = Paths()
     if len(contours.collections) == 0:
         return paths
     for path in contours.collections[0].get_paths():
         paths.append(Path(path.vertices[:, 0] + 1j*path.vertices[:, 1]))
     pyplot.close(figure)
     return paths
开发者ID:andrenarchy,项目名称:pseudopy,代码行数:11,代码来源:nonnormal.py

示例11: plot_contour

    def plot_contour(self, **kwargs):
        """Contour plot of the xy plane

        Parameters
        ----------
        **kwargs
            Forwarded to `plt.tricontour()`.
        """
        x, y, _ = self.pos
        contour = plt.tricontour(x, y, self.data, **kwargs)
        self._decorate_plot()
        return contour
开发者ID:haibiao,项目名称:pybinding,代码行数:12,代码来源:results.py

示例12: test_tri_smooth_contouring

def test_tri_smooth_contouring():
    # Image comparison based on example tricontour_smooth_user.
    n_angles = 20
    n_radii = 10
    min_radius = 0.15

    def z(x, y):
        r1 = np.sqrt((0.5 - x) ** 2 + (0.5 - y) ** 2)
        theta1 = np.arctan2(0.5 - x, 0.5 - y)
        r2 = np.sqrt((-x - 0.2) ** 2 + (-y - 0.2) ** 2)
        theta2 = np.arctan2(-x - 0.2, -y - 0.2)
        z = -(
            2 * (np.exp((r1 / 10) ** 2) - 1) * 30.0 * np.cos(7.0 * theta1)
            + (np.exp((r2 / 10) ** 2) - 1) * 30.0 * np.cos(11.0 * theta2)
            + 0.7 * (x ** 2 + y ** 2)
        )
        return (np.max(z) - z) / (np.max(z) - np.min(z))

    # First create the x and y coordinates of the points.
    radii = np.linspace(min_radius, 0.95, n_radii)
    angles = np.linspace(0 + n_angles, 2 * np.pi + n_angles, n_angles, endpoint=False)
    angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1)
    angles[:, 1::2] += np.pi / n_angles
    x0 = (radii * np.cos(angles)).flatten()
    y0 = (radii * np.sin(angles)).flatten()
    triang0 = mtri.Triangulation(x0, y0)  # Delaunay triangulation
    z0 = z(x0, y0)
    xmid = x0[triang0.triangles].mean(axis=1)
    ymid = y0[triang0.triangles].mean(axis=1)
    mask = np.where(xmid * xmid + ymid * ymid < min_radius * min_radius, 1, 0)
    triang0.set_mask(mask)

    # Then the plot
    refiner = mtri.UniformTriRefiner(triang0)
    tri_refi, z_test_refi = refiner.refine_field(z0, subdiv=4)
    levels = np.arange(0.0, 1.0, 0.025)
    plt.triplot(triang0, lw=0.5, color="0.5")
    plt.tricontour(tri_refi, z_test_refi, levels=levels, colors="black")
开发者ID:tonysyu,项目名称:matplotlib,代码行数:38,代码来源:test_triangulation.py

示例13: tricontourf_deformed

def tricontourf_deformed(a, mesh, d,  name, cmap, dpi, magf):
    """Plot contour with the tricoutour function and the boundary line with
    the boundary node.

    """
    fig = plt.figure(name, dpi=dpi)
    ax1 = fig.add_subplot(1, 1, 1, aspect='equal')
    c = mesh.nodes_coord
    bn = mesh.boundary_nodes

    xx, yy, zz = c[:, 0]+d[::2]*magf, c[:, 1]+d[1::2]*magf, a

    dx = d[::2]*magf
    dy = d[1::2]*magf

    ccx = np.append(c[bn[:, 1], 0]+dx[bn[:, 1]], c[bn[0, 1], 0]+dx[bn[0, 1]])
    ccy = np.append(c[bn[:, 1], 1]+dy[bn[:, 1]], c[bn[0, 1], 1]+dy[bn[0, 1]])
    plt.plot(ccx, ccy, '-k')

    triangles = []
    for n1, n2, n3, n4 in mesh.ele_conn:
        triangles.append([n1, n2, n3])
        triangles.append([n1, n3, n4])

    triangles = np.asarray(triangles)

    CS2 = plt.tricontourf(xx, yy, triangles, zz, N=10, origin='lower',
                          cmap=cmap)

    CS3 = plt.tricontour(xx, yy, triangles, zz, N=10, origin='lower',colors='k')


    plt.xlabel(r'$x$', fontsize=14)
    plt.ylabel(r'$y$', fontsize=14)

    divider = make_axes_locatable(ax1)
    cax = divider.append_axes("right", size=0.3, pad=0.1)

    cbar = plt.colorbar(CS2, cax=cax)
    cbar.ax.set_label(name, fontsize=12)

    plt.clabel(CS3, fontsize=8, colors='k', fmt='%1.1f')

    limits=plt.axis('off')
    # plt.savefig('1.png', transparent=True, dpi=300)
    #plt.axes().set_aspect('equal')
    #plt.axes().autoscale_view(True, True, True)

    plt.draw()
开发者ID:nasseralkmim,项目名称:eldypy,代码行数:49,代码来源:plotter.py

示例14: plot

 def plot(self, epsilons, **kwargs):
     epsilons = list(numpy.sort(epsilons))
     padepsilons = [epsilons[0]*0.9] + epsilons + [epsilons[-1]*1.1]
     X = []
     Y = []
     Z = []
     for epsilon in padepsilons:
         paths = self.contour_paths(epsilon)
         for path in paths:
             X += list(numpy.real(path.vertices[:-1]))
             Y += list(numpy.imag(path.vertices[:-1]))
             Z += [epsilon] * (len(path.vertices) - 1)
     contours = pyplot.tricontour(X, Y, Z, levels=epsilons,
                                  colors=pyplot.rcParams['axes.color_cycle']
                                  )
     plot_finish(contours, **kwargs)
     return contours
开发者ID:francispoulin,项目名称:pseudopy,代码行数:17,代码来源:normal.py

示例15: contour

  def contour(self, prop=None):
    if(prop=='Tdust'):
        data=self.T[0:len(self.x)]['1']
        label="Dust temperature [K]"
    elif(prop=='rho'):
        data=np.log(self.rho[0:len(self.x)]['1'])
        label="Log some density [?]"
    else:
        try:
            data=self.prop
            label='Unknown property'
        except:
            print "Please specify property to plot. Valid properties are [Tdust, rho]"
            return

    x_au = self.x/1.49e13
    y_au = self.y/1.49e13

    tri=Triangulation(x_au,y_au)

    plt.close('all')
    plt.figure()
    ax=plt.subplot(111)
    ax.set_xscale("log",nonposx='clip')
    ax.set_yscale("log",nonposy='clip')
    ax.set_xlim([0.1,200])
    ax.set_ylim([0.1,200])
    plt.xlabel('r [AU]')
    plt.ylabel('z [AU]')

    nmax=data.max()
    nmin=data.min()
    levels=np.arange(12) * (nmax-nmin)/12. + nmin
    plt.tricontourf(tri, data, levels)
    cbar=plt.colorbar()
    cbar.set_label(label)

    CS=plt.tricontour(tri, data, levels, colors='black', linewidths=1.5)
    plt.clabel(CS, fontsize=8, inline=1)
    cbar.add_lines(CS)

    plt.triplot(tri, color='black', alpha=0.2)
开发者ID:christianbrinch,项目名称:pythonToolkit,代码行数:42,代码来源:radmc2lime.py


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