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


Python pyplot.tripcolor函数代码示例

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


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

示例1: showSolution

 def showSolution(self,dim=2):
     from mpl_toolkits.mplot3d import Axes3D
     from matplotlib import cm, pyplot
     x,y,tri,solution,grad = [],[],[],[],[]
     for n in self.node:
         x.append(n.x)
         y.append(n.y)
         solution.append(n.value)
     for e in self.element:
         tri.append([n.id for n in e.node])
         grad.append(e.grad())
     if dim==2:
         pyplot.figure(figsize=(17,6))
         pyplot.subplot(1,2,1)
         pyplot.title("Solution")
         pyplot.tripcolor(x, y, tri, solution, cmap=cm.jet,  edgecolors='black')
         pyplot.colorbar()
         pyplot.subplot(1,2,2)
         pyplot.title("Gradient")
         pyplot.tripcolor(x, y, tri, grad, cmap=cm.jet,  edgecolors='black')
         pyplot.colorbar()
     elif dim==3:
         fig = pyplot.figure()
         ax = fig.gca(projection='3d')
         ax.plot_trisurf(x, y, tri, z, cmap=cm.jet, linewidth=0.2)
     pyplot.show()
开发者ID:JeroenMulkers,项目名称:fem2d,代码行数:26,代码来源:mesh.py

示例2: el_plot

def el_plot(data, Map=False, show=True):
    """
    Plot the elevation for the region from the last time series
    
    :Parameters:
        **data** -- the standard python data dictionary
        
        **Map** -- {True, False} (optional): Optional argument.  If True,
            the elevation will be plotted on a map.  
    """
    trigrid = data['trigrid']
    plt.gca().set_aspect('equal')
    plt.tripcolor(trigrid, data['zeta'][-1,:])
    plt.colorbar()
    plt.title("Elevation")
    if Map:
        #we set the corners of where the map should show up
        llcrnrlon, urcrnrlon = plt.xlim()
        llcrnrlat, urcrnrlat = plt.ylim()
        #we construct the map.  Note that resolution serves to increase
        #or decrease the detail in the coastline.  Currently set to 
        #'i' for 'intermediate'
        m = Basemap(llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, \
            resolution='i', suppress_ticks=False)
        #set color for continents.  Default is grey.
        m.fillcontinents(color='ForestGreen')
        m.drawmapboundary()
        m.drawcoastlines()
    if show:
        plt.show()
开发者ID:RobieH,项目名称:Karsten-datatools,代码行数:30,代码来源:plottools.py

示例3: field

def field(domain, z, title, clim = None,  path=None, save=True, show =
          False, ics=1, ext='.png', cmap=plt.cm.jet, fmt=None):
    """
    Given a domain, plot the nodal value z
   
    :param domain: :class:`~polyadcirc.run_framework.domain`
    :param z: :class:`numpy.ndarray`
    :param string title: plot title
    :param clim: :class:`numpy.clim`
    :type path: string or None
    :param path: directory to store plots
    :type save: bool
    :param save: flag for whether or not to save plots
    :type show: bool
    :param show: flag for whether or not to show plots
    :param int ics:  polar coordinate option (1 = cart coords, 2 = polar
        coords)
    :param string ext: file extension
    :param callable fmt: formatter for color bar, takes ``(x, pos)`` returns
        ``string`` 

    """
    if path is None:
        path = os.getcwd()
    plt.figure()
    plt.tripcolor(domain.triangulation, z, shading='gouraud',
                  cmap=cmap)
    plt.gca().set_aspect('equal')
    plt.autoscale(tight=True)
    if clim:
        plt.clim(clim[0], clim[1])
    add_2d_axes_labels(ics=ics)    
    colorbar(fmt=fmt)
    #plt.title(title)
    save_show(os.path.join(path, 'figs', title), save, show, ext)
开发者ID:lcgraham,项目名称:PolyADCIRC,代码行数:35,代码来源:plotADCIRC.py

示例4: draw

 def draw(self, x = (), y=()):
     #px,py = self.points.to(self.env_model.ROW_COL)
     plt.tripcolor(self.x, self.y, self.mesh.faces, facecolors=self.zfaces, edgecolors='k')
     if len(x) != 0:
         plt.plot(x, y)
     plt.axis('equal')
     plt.show()
开发者ID:kezilu,项目名称:pextant,代码行数:7,代码来源:MeshVisualizer.py

示例5: plotstate

def plotstate(Mesh, U, field, fname):
	V = Mesh['V']
	E = Mesh['E']
	BE = Mesh['BE']

	f = plt.figure(figsize=(12,6))

	F = pu.getField(U, field)
	plt.tripcolor(V[:,0], V[:,1], triangles=E, facecolors=F, shading='flat', vmin=1.55, vmax=1.9)

	for i in range(len(BE)):
		x = [V[BE[i,0],0], V[BE[i,1],0]]
		y = [V[BE[i,0],1], V[BE[i,1],1]]
		plt.plot(x, y, '-', linewidth=2, color='black')
	
	#dosave = (len(fname) != 0)

	plt.axis('equal')

	#plt.axis([-100, 100,-100, 100])
	plt.axis([-2, 10,-4, 4])
	plt.colorbar()
	#plt.clim(0, 0.8)
	plt.title(field, fontsize=16)

	f.tight_layout()
	plt.show()#block=(not dosave))
	#if (dosave):
	plt.savefig(fname)
	
	plt.close(f)
开发者ID:Rob-Rau,项目名称:EbbCFD,代码行数:31,代码来源:MakeEbbVideo.py

示例6: quick_plot

def quick_plot(bmi, name, **kwds):
    gid = bmi.var_grid(name)
    gtype = bmi.grid_type(gid)
    grid = bmi.grid[gid]

    x, y = grid.node_x.values, grid.node_y.values
    z = bmi.get_value(name)

    x_label = "{name} ({units})".format(
        name=grid.node_x.standard_name, units=grid.node_x.units
    )
    y_label = "{name} ({units})".format(
        name=grid.node_y.standard_name, units=grid.node_y.units
    )

    if gtype in ("unstructured_triangular",):
        tris = bmi.grid_face_node_connectivity(gid).reshape((-1, 3))
        plt.tripcolor(x, y, tris, z, **kwds)
    elif gtype in ("uniform_rectilinear", "structured_quad"):
        shape = bmi.grid_shape(gid)
        spacing = bmi.grid_spacing(gid)
        origin = bmi.grid_origin(gid)
        x = np.arange(shape[-1]) * spacing[-1] + origin[-1]
        y = np.arange(shape[-2]) * spacing[-2] + origin[-2]
        plt.pcolormesh(x, y, z.reshape(shape), **kwds)
    else:
        raise ValueError("no plotter for {gtype}".format(gtype=gtype))

    plt.axis("tight")
    plt.gca().set_aspect("equal")
    plt.xlabel(x_label)
    plt.ylabel(y_label)

    cbar = plt.colorbar()
    cbar.ax.set_ylabel("{name} ({units})".format(name=name, units=bmi.var_units(name)))
开发者ID:csdms,项目名称:pymt,代码行数:35,代码来源:bmi_plot.py

示例7: field

def field(domain, z, title, clim = None,  path=None, save=True, show =
          False, ics=1, ext='.png', cmap=plt.cm.jet):
    """
    Given a domain, plot the nodal value z
   
    :param domain: :class:`~polyadcirc.run_framework.domain`
    :param z: :class:`np.array`
    :param string title: plot title
    :param clim: :class:`np.clim`
    :type path: string or None
    :param path: directory to store plots
    :type save: boolean
    :param save: flag for whether or not to save plots
    :type show: boolean
    :param show: flag for whether or not to show plots
    :param int ics:  polar coordinate option (1 = cart coords, 2 = polar
        coords)
    :param string ext: file extension

    """
    if path == None:
        path = os.getcwd()
    plt.figure()
    plt.tripcolor(domain.triangulation, z, shading='gouraud',
                  cmap=cmap)
    plt.gca().set_aspect('equal')
    plt.autoscale(tight=True)
    if clim:
        plt.clim(clim[0], clim[1])
    add_2d_axes_labels(ics)    
    colorbar()
    #plt.title(title)
    save_show(path+'/figs/'+title, save, show, ext)
开发者ID:alarcher,项目名称:PolyADCIRC,代码行数:33,代码来源:plotADCIRC.py

示例8: mplot_function

def mplot_function(f, vmin, vmax, logscale):
    mesh = f.function_space().mesh()
    if (mesh.geometry().dim() != 2):
        raise AttributeError('Mesh must be 2D')
    # DG0 cellwise function
    if f.vector().size() == mesh.num_cells():
        C = f.vector().array()
        if logscale:
            return plt.tripcolor(mesh2triang(mesh), C, vmin=vmin, vmax=vmax, norm=cls.LogNorm() )
        else:
            return plt.tripcolor(mesh2triang(mesh), C, vmin=vmin, vmax=vmax)
    # Scalar function, interpolated to vertices
    elif f.value_rank() == 0:
        C = f.compute_vertex_values(mesh)
        if logscale:
            return plt.tripcolor(mesh2triang(mesh), C, vmin=vmin, vmax=vmax, norm=cls.LogNorm() )
        else:
            return plt.tripcolor(mesh2triang(mesh), C, shading='gouraud', vmin=vmin, vmax=vmax)
    # Vector function, interpolated to vertices
    elif f.value_rank() == 1:
        w0 = f.compute_vertex_values(mesh)
        if (len(w0) != 2*mesh.num_vertices()):
            raise AttributeError('Vector field must be 2D')
        X = mesh.coordinates()[:, 0]
        Y = mesh.coordinates()[:, 1]
        U = w0[:mesh.num_vertices()]
        V = w0[mesh.num_vertices():]
        C = np.sqrt(U*U+V*V)
        return plt.quiver(X,Y,U,V, C, units='x', headaxislength=7, headwidth=7, headlength=7, scale=4, pivot='middle')
开发者ID:afeiNick,项目名称:Computational-and-Variational-Methods-for-Inverse-Problems,代码行数:29,代码来源:nb.py

示例9: test_tripcolor

def test_tripcolor():
    x = np.asarray([0, 0.5, 1, 0,   0.5, 1,   0, 0.5, 1, 0.75])
    y = np.asarray([0, 0,   0, 0.5, 0.5, 0.5, 1, 1,   1, 0.75])
    triangles = np.asarray([
        [0, 1, 3], [1, 4, 3],
        [1, 2, 4], [2, 5, 4],
        [3, 4, 6], [4, 7, 6],
        [4, 5, 9], [7, 4, 9], [8, 7, 9], [5, 8, 9]])

    # Triangulation with same number of points and triangles.
    triang = mtri.Triangulation(x, y, triangles)

    Cpoints = x + 0.5*y

    xmid = x[triang.triangles].mean(axis=1)
    ymid = y[triang.triangles].mean(axis=1)
    Cfaces = 0.5*xmid + ymid

    plt.subplot(121)
    plt.tripcolor(triang, Cpoints, edgecolors='k')
    plt.title('point colors')

    plt.subplot(122)
    plt.tripcolor(triang, facecolors=Cfaces, edgecolors='k')
    plt.title('facecolors')
开发者ID:JabberDabber7Big,项目名称:zipper,代码行数:25,代码来源:test_triangulation.py

示例10: triangle_vert_plot

def triangle_vert_plot(filename, args):
    dset = gusto_dataset.GustoDataset(filename)
    x = dset.get_vert_variable('x1')
    z = dset.get_vert_variable('x3')
    f = dset.get_vert_variable(args.data)
    plt.tripcolor(x, z, f)
    plt.axis('equal')
开发者ID:jzrake,项目名称:gusto,代码行数:7,代码来源:plot.py

示例11: draw_map

def draw_map(triangulation, options):
    '''
    get the triangle tuple (concentration, triangle] prepared before
    and draw the map of triangles
    options :
    "map_format": "svg",
    "map_file": "../../mapa"
    '''
    lab_x = options['xlabel'] if value_set(options, 'xlabel') else 'mesh X coord'
    lab_y = options['ylabel'] if value_set(options, 'ylabel') else 'mesh Y coord'
    lab_tit = options['title'] if value_set(options, 'title') else 'Map of concentrations'
    
    
    plt.figure()
    plt.gca().set_aspect('equal')
    plt.tripcolor(triangulation['x_np'],
                  triangulation['y_np'],
                  triangulation['triangles'],
                  facecolors=triangulation['zfaces'],
                  edgecolors='k')
    plt.colorbar()
    plt.title(lab_tit)
    plt.xlabel(lab_x)
    plt.ylabel(lab_y)
    
    plt.savefig(options["map_file"], format=options["map_format"])               
开发者ID:jirivrany,项目名称:riskflow123d-post,代码行数:26,代码来源:mapcon.py

示例12: plot_latlon_tri

def plot_latlon_tri(lon=None, lat=None, data=None, title='Title', 
	vmin_in=CBAR_MINT, vmax_in=CBAR_MAXT):
	triang = tri.Triangulation(lon, lat)
	fig, ax = plt.subplots()
	plt.gca().set_aspect('equal')
	plt.tripcolor(triang, data, cmap=cm.jet, vmin=vmin_in, vmax=vmax_in)
	label_plot(fig, ax, title)
	return fig
开发者ID:danmfisher,项目名称:TCC_SSWE,代码行数:8,代码来源:lplot.py

示例13: triangle_variable_plot

def triangle_variable_plot(filename, args):
    dset = gusto_dataset.GustoDataset(filename)
    x = dset.get_cell_variable('x1')
    z = dset.get_cell_variable('x3')
    f = dset.get_cell_variable('dg')
    plt.tripcolor(x, z, f)
    plt.axis('equal')
    plt.colorbar()
开发者ID:jzrake,项目名称:gusto,代码行数:8,代码来源:plot.py

示例14: plot_faces

def plot_faces(nodes,faces,fn,cmap=None):
    fn = np.ma.array(fn,mask=~np.isfinite(fn))
    assert(fn.size == faces.shape[0])
    if cmap is None:
        cmap = plt.get_cmap('jet')
    cmap.set_bad('w',1.)
    plt.gca()
    plt.tripcolor(nodes[:,0],nodes[:,1],faces,facecolors=fn,
                  edgecolor='k',cmap=cmap)
    plt.colorbar()
开发者ID:order,项目名称:lcp-research,代码行数:10,代码来源:tri_mesh_viewer.py

示例15: postprocessor

def postprocessor(nodes, val):
    x = nodes[:, 0]
    y = nodes[:, 1]

    fig = plt.figure()
    plt.gca().set_aspect('equal')
    plt.tripcolor(x,y,elements,facecolors=val,edgecolors='k')
    plt.colorbar()
    plt.title("Poisson's equation")
    plt.xlabel('x')
    plt.ylabel('y')
    #plt.savefig("FEM.png")
    plt.show()
开发者ID:GuiAlmeidaPC,项目名称:FEM,代码行数:13,代码来源:unsteady2dfem1.py


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