• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyplot.triplot函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: plotgrid_ll

def plotgrid_ll(data,size,ll,nore):
    if nore=='n':
        num=dt.closest_node(data,ll)
        region={}
        region['region']=[data['nodexy'][num,0]-size,data['nodexy'][num,0]+size,data['nodexy'][num,1]-size,data['nodexy'][num,1]+size]
        idx=dt.get_nodes_xy(data,region)
        plt.triplot(data['trigridxy'],lw=.5)
        for i in idx:
            plt.text(data['nodexy'][i,0],data['nodexy'][i,1],("%d"%i),fontsize=10,bbox={'facecolor':'white', 'alpha':.7, 'pad':3})
        region2={}
        region2['region']=[data['nodexy'][num,0]-(size*2),data['nodexy'][num,0]+(size*2),data['nodexy'][num,1]-(size*2),data['nodexy'][num,1]+(size*2)]
        plt.axis(region2['region'])
        plt.show()
    if nore=='e':
        num=dt.closest_element(data,ll)
        region={}
        region['region']=[data['uvnode'][num,0]-size,data['uvnode'][num,0]+size,data['uvnode'][num,1]-size,data['uvnode'][num,1]+size]
        idx=dt.get_elements_xy(data,region)
        plt.triplot(data['trigridxy'],lw=.5)
        for i in idx:
            plt.text(data['uvnode'][i,0],data['uvnode'][i,1],("%d"%i),fontsize=10,bbox={'facecolor':'white', 'alpha':.7, 'pad':3})
        region2={}
        region2['region']=[data['uvnode'][num,0]-(size*2),data['uvnode'][num,0]+(size*2),data['uvnode'][num,1]-(size*2),data['uvnode'][num,1]+(size*2)]
        plt.axis(region2['region'])
        plt.show()
开发者ID:ilai,项目名称:workspace_python,代码行数:25,代码来源:plottools.py


示例2: main

def main():
    points = [(1, 0), (1, 1), (-1, 1), (-1, -1), (1, -1), (1, 0)]
    facets = round_trip_connect(0, len(points)-1)

    circ_start = len(points)
    points.extend(
            (3 * np.cos(angle), 3 * np.sin(angle))
            for angle in np.linspace(0, 2*np.pi, 30, endpoint=False))

    facets.extend(round_trip_connect(circ_start, len(points)-1))

    def needs_refinement(vertices, area):
        bary = np.sum(np.array(vertices), axis=0)/3
        max_area = 0.001 + (la.norm(bary, np.inf)-1)*0.01
        return bool(area > max_area)

    info = triangle.MeshInfo()
    info.set_points(points)
    info.set_holes([(0, 0)])
    info.set_facets(facets)

    mesh = triangle.build(info, refinement_func=needs_refinement)

    mesh_points = np.array(mesh.points)
    mesh_tris = np.array(mesh.elements)

    import matplotlib.pyplot as pt
    pt.triplot(mesh_points[:, 0], mesh_points[:, 1], mesh_tris)
    pt.show()
开发者ID:OlegJakushkin,项目名称:meshpy,代码行数:29,代码来源:test_triangle.py


示例3: get_Triangulation

def get_Triangulation(domain, path=None, save=True, show=False, ics=1,
                      ext='.png'):
    """
    :param domain: :class:`~polyadcirc.run_framework.domain`
    :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: coordinate system (1 cartisian, 2 polar)
    :param string ext: file extesion
    :returns: :class:`matplotlib.tri.Triangulation`

    """

    x = np.array([n.x for n in domain.node.itervalues()])
    y = np.array([n.y for n in domain.node.itervalues()])
    triangles = np.array([e-1 for e in domain.element.itervalues()])
    triangulation = tri.Triangulation(x, y, triangles)
    plt.figure()
    if path == None:
        path = os.getcwd()
    if not os.path.exists(path+'/figs'):
        fm.mkdir(path+'/figs')
    if save or show:
        plt.triplot(triangulation, 'g-')
        plt.title('grid')
        plt.gca().set_aspect('equal')
        add_2d_axes_labels(ics)    
        save_show(path+'/figs/grid', save, show, ext)
    domain.triangulation = triangulation
    return triangulation
开发者ID:alarcher,项目名称:PolyADCIRC,代码行数:33,代码来源:plotADCIRC.py


示例4: colorizedDelaunay

def colorizedDelaunay(tri,coordCentersX,coordCentersY,lcircle):
    "Basic coloration function for simple vue of the Triangulation. No consideration of node propreties"
    plt.triplot(coordCentersX, coordCentersY, tri.vertices.copy())#manage triangle edges color here
    plt.plot(coordCentersX, coordCentersY, 'o', markersize=1,markerfacecolor='green', markeredgecolor='red')
    plt.show()
    
    return
开发者ID:dgormez,项目名称:pattern-recognition,代码行数:7,代码来源:pattern-reco.py


示例5: fun_display_category_in_triang2D

def fun_display_category_in_triang2D(X, Y, category_name, title="aNother beautiful plot"):
    """
    The function does almost list the one called fun_display_category_in_2D
    except that it uses some triangulation to show the data.
    """
    names_gender = []
    for name in category_name:
        names_gender.append(name[0])

    indices_M = [i for i, s in enumerate(names_gender) if s[0] == "M"]
    indices_F = [j for j, s in enumerate(names_gender) if s[0] == "F"]

    indices_M = np.asarray(indices_M)
    indices_F = np.asarray(indices_F)

    # plt.figure()

    triang = tri.Triangulation(X[indices_M], Y[indices_M])
    # Mask off unwanted triangles.
    xmid = X[triang.triangles].mean(axis=1)
    ymid = Y[triang.triangles].mean(axis=1)
    plt.triplot(triang, "bs-")

    triang = tri.Triangulation(X[indices_F], Y[indices_F])
    # Mask off unwanted triangles.
    xmid = X[triang.triangles].mean(axis=1)
    ymid = Y[triang.triangles].mean(axis=1)
    plt.triplot(triang, "or-")

    plt.xlabel("dimension 1")
    plt.ylabel("dimension 2")
    plt.title("another beautiful plot")
    plt.axis([-1, 1, -1, 1])
    plt.draw()
开发者ID:mrbonsoir,项目名称:random_notebooks,代码行数:34,代码来源:visualisationTools.py


示例6: graph_grid

    def graph_grid(self, debug=False):
        ''' 2D xy plot of bathymetry and mesh.
            No inputs required so far'''
        if debug or self._debug:
            print 'Plotting grid...'
        nv = self._var.nv.T -1
        h = self._var.h
        tri = Tri.Triangulation(self._var.lon, self._var.lat, triangles=nv)

        levels=np.arange(-100,-4,1)   # depth contours to plot

        fig = plt.figure(figsize=(18,10))
        plt.rc('font',size='22')
        ax = fig.add_subplot(111,aspect=(1.0/np.cos(np.mean(self._var.lat)*np.pi/180.0)))
        plt.tricontourf(tri, -h,levels=levels,shading='faceted',cmap=plt.cm.gist_earth)
        plt.triplot(tri)
        plt.ylabel('Latitude')
        plt.xlabel('Longitude')
        plt.gca().patch.set_facecolor('0.5')
        cbar=plt.colorbar()
        cbar.set_label('Water Depth (m)', rotation=-90,labelpad=30)

        scale = 1
        ticks = ticker.FuncFormatter(lambda lon, pos: '{0:g}'.format(lon/scale))
        ax.xaxis.set_major_formatter(ticks)
        ax.yaxis.set_major_formatter(ticks)
        plt.grid()
        plt.show()

        if debug or self._debug:
            print '...Passed'
开发者ID:wesleybowman,项目名称:FVCOM-PySeidon,代码行数:31,代码来源:plotsFvcom.py


示例7: VisTris

	def VisTris(self):
		de = Delaunay(self.pts)
		print de
		points = np.array(self.pts)
		plt.triplot(points[:,0], points[:,1], de.simplices.copy())
		plt.plot(points[:,0], points[:,1], 'o')
		plt.show()
开发者ID:TimSC,项目名称:srtm-terrain,代码行数:7,代码来源:simplifymesh.py


示例8: Plot_Occ

def Plot_Occ(tlist,vlist,angles,offset,OCCs,index):
    if index>len(OCCs):
        sys.exit("Index too large for occultation")
    up=np.array([0,0.3977,0.9175])
    M=Ortho_Proj(OCCs[index-1].E,up)
    R=Rot_Matrix(angles[0],angles[1],angles[2],OCCs[index-1].Meantime,0)
    MR=np.dot(M,R.transpose())
    vlist2=np.dot(MR,vlist.transpose()).transpose()
    vlist2=vlist2[:,0:2]
    V=np.dot(M,OCCs[index-1].V.transpose())
    v=V[0:2]
    vlist2[:,0]=vlist2[:,0]+offset[0]
    vlist2[:,1]=vlist2[:,1]+offset[1]
    #plt.figure(figsize=(50,50))
    plt.gca().set_aspect('equal')
    plt.triplot(np.array(vlist2[:,0]).flatten(),np.array(vlist2[:,1]).flatten(), tlist-1, 'g-',alpha=0.5)
    for j in range(0,len(OCCs[index-1].Chordtype)):
        a=OCCs[index-1].Chords[j,0:2]
        b=OCCs[index-1].Chords[j,2:4]
        ctype=OCCs[index-1].Chordtype[j]
        if ctype>=0:
            plt.plot([a[0],b[0]],[a[1],b[1]],'k-')
        if ctype<0:
            plt.plot([a[0],b[0]],[a[1],b[1]],'k--')
    plt.show()
开发者ID:matvii,项目名称:ADAM,代码行数:25,代码来源:utils.py


示例9: draw_pdf_contours

def draw_pdf_contours(dist, border=False, nlevels=200, subdiv=8, **kwargs):
    '''Draws pdf contours over an equilateral triangle (2-simplex).

    Arguments:

        `dist`: A distribution instance with a `pdf` method.

        `border` (bool): If True, the simplex border is drawn.

        `nlevels` (int): Number of contours to draw.

        `subdiv` (int): Number of recursive mesh subdivisions to create.

        kwargs: Keyword args passed on to `plt.triplot`.
    '''
    from matplotlib import ticker, cm
    import math
 
    refiner = tri.UniformTriRefiner(_triangle)
    trimesh = refiner.refine_triangulation(subdiv=subdiv)
    pvals = [dist.pdf(xy2bc(xy)) for xy in zip(trimesh.x, trimesh.y)]
 
    plt.tricontourf(trimesh, pvals, nlevels, **kwargs)
    plt.axis('equal')
    plt.xlim(0, 1)
    plt.ylim(0, 0.75**0.5)
    plt.axis('off')
    if border is True:
        plt.hold(1)
        plt.triplot(_triangle, linewidth=1)
开发者ID:zedoul,项目名称:air,代码行数:30,代码来源:main.py


示例10: webcam

def webcam():
  if __name__=='__main__':
    capture=cv.CaptureFromCAM(0)
    cv.NamedWindow('image')
    
    while  True:
      frame=cv.QueryFrame(capture)
      cv.ShowImage('image',frame)
      k=cv.WaitKey(10)
      if k%256==27:
        break

    cv.DestroyWindow('image')

  img=np.asarray(frame[:,:])
  img=img[:,:,0]
  im = Image.fromarray(img)

  a=[]
  img = cv2.medianBlur(img,5) 
  th2 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,\
              cv2.THRESH_BINARY,3,1)
  for i in range (0,th2.shape[0]) :
          for j in range(0,th2.shape[1]):
                  if th2[i,j]==0 :
                        a.append((j,-i))
  points=np.asarray(a)
  for i in a :
          del i
  tri = Delaunay(points)
  plt.triplot(points[:,0], points[:,1], tri.simplices.copy(),linewidth=0.5,color='b')
  #plt.plot(points[:,0], points[:,1], 'o')
  plt.xticks([]), plt.yticks([])
  plt.show()
开发者ID:paragbansal,项目名称:Project,代码行数:34,代码来源:final.py


示例11: 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


示例12: show

def show(verts1, verts2, tris1, tris2):
    plt.subplot(211)
    plt.xlabel('x')
    plt.ylabel('y')
    plt.triplot(verts1[:,0], verts1[:,1], tris1, 'g-')
    Tv = numpy.ones([len(verts1[:,0]),1])
    plt.triplot(verts2[:,0]+Tv[0,:]*1.25, verts2[:,1], tris2, 'r-')
开发者ID:athoens,项目名称:NumPDE2016,代码行数:7,代码来源:meshes.py


示例13: __init__

    def __init__(self,xrange,yrange,pointsArray,simplices,initPosDist,initVelDist,initParticles):
        self.fig = plt.figure(1)				#create plot window
        plt.ion()
        self.ax = plt.gca()	
        self.ax.set_autoscale_on(False)
        self.ax.axis([xrange[0],xrange[1],yrange[0],yrange[1]])	#set boundaries

        self.tri_xy = pointsArray		#includes [[x0 x1 x2 ...		points to triangulate
						#           y0 y1 y2 ...  ]]
	self.tri_simplices = simplices		#includes [[p1,p4,p2],[p8,p4,p6]...]	triangulation of said points
	print self.tri_simplices
        plt.triplot(self.tri_xy[:,0],self.tri_xy[:,1],self.tri_simplices)
        
        self.ax.plot(self.tri_xy[:,0], self.tri_xy[:,1], 'o')

        self.fig.show()
        self.e_array = []

        self.xmin = xrange[0]
        self.xmax = xrange[1]
        self.ymin = yrange[0]
        self.ymax = yrange[1]

        for i in range(0, initParticles):
            a = particle(initPosDist[0],initPosDist[1],initVelDist[0],initVelDist[1])
            self.e_array.append([a, self.ax.plot(a.xpos, a.ypos, 'ro')])
开发者ID:TimVyhnanek,项目名称:mesoBTE,代码行数:26,代码来源:mesh.py


示例14: graphGrid

    def graphGrid(self,narrowGrid=False, plot=False):
        #nx.draw(self.graph, self.pointIDXY)
        #plt.show()

        #lat = self.data.variables['lat'][:]
        #lon = self.data.variables['lon'][:]
        #nv = self.data.variables['nv'][:].T -1
        #h = self.data.variables['h'][:]
        #lat = self.self.lat
        #lon = self.lon
        #trinodes = self.trinodes[:]
        #h = self.h

        tri = Tri.Triangulation(self.lon, self.lat, triangles=self.trinodes) 
        # xy or latlon based on how you are #Grand Passage

        #levels=np.arange(-38,6,1)   # depth contours to plot

        fig = plt.figure(figsize=(18,10))
        plt.rc('font',size='22')
        ax = fig.add_subplot(111,aspect=(1.0/np.cos(np.mean(self.lat)*np.pi/180.0)))
        #plt.tricontourf(tri,-self.h,shading='faceted',cmap=plt.cm.gist_earth)
        plt.triplot(tri, color='white', linewidth=0.5)
        plt.ylabel('Latitude')
        plt.xlabel('Longitude')
        plt.gca().patch.set_facecolor('0.5')
        #cbar=plt.colorbar()
        #cbar.set_label('Water Depth (m)', rotation=-90,labelpad=30)

        scale = 1
        ticks = ticker.FuncFormatter(lambda lon, pos: '{0:g}'.format(lon/scale))
        ax.xaxis.set_major_formatter(ticks)
        ax.yaxis.set_major_formatter(ticks)
        plt.grid()

        maxlat, maxlon = np.max(self.maxcoordinates,axis=0)
        minlat, minlon = np.min(self.mincoordinates,axis=0)
        if narrowGrid:
            ax.set_xlim(minlon,maxlon)
            ax.set_ylim(minlat,maxlat)


        zz = len(self.elements)
        for i,v in enumerate(self.elements):
            source = self.pointIDXY[v[0]]
            target = self.pointIDXY[v[-1]]
            lab = '({:.6},{:.6})-({:.6},{:.6})'.format(source[0], source[1],
                                                       target[0], target[1])

            plt.scatter(self.lonc[v], self.latc[v],
                        s=80, label=lab, c=plt.cm.Set1(i/zz))

        #plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=2, ncol=3,fontsize='14', borderaxespad=0.)
        plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=2, ncol=3)
        #plt.legend()
        if plot:
            plt.ylabel('Latitude')
            plt.xlabel('Longitude')
            plt.show()
开发者ID:GrumpyNounours,项目名称:PySeidon,代码行数:59,代码来源:shortest_element_path.py


示例15: delaunay

def delaunay(dataName,dataType,value):
	v_arr=genfromtxt(dataName + str(value) + dataType,delimiter=',' )
	data = np.array([[row[0],row[1]] for row in v_arr])
	dln = sp.spatial.Delaunay(data)
	plt.triplot(data[:,0],data[:,1],dln.simplices.copy(),linewidth=0.5,color='b',marker='.')
	plt.xlim(300,700);plt.ylim(300,700);
	plt.savefig('delaun_' + str(value) + '.png',dpi=200)
	print 'Saved Delaunay @ t=' + str(value)
开发者ID:peterwittek,项目名称:GPUE,代码行数:8,代码来源:vis.py


示例16: PlotMesh

def PlotMesh(M):
  if M.version==0:
    plt.triplot(M.q[:,0],M.q[:,1],M.me,'bo-')
  elif M.version==1:
    plt.triplot(M.q[0],M.q[1],M.me,'bo-')
  plt.axis('equal')
  plt.axis('off')
  plt.show()
开发者ID:gscarella,项目名称:pyOptFEM,代码行数:8,代码来源:mesh.py


示例17: plot_compact

def plot_compact(u, t, stepcounter): 
    if stepcounter % 5 == 0:
        uEuclidnorm = project(u, V); ax.cla(); fig = plt.gcf(); fig.set_size_inches(16, 6.5)
        plt.subplot(1, 2, 1); mplot_function(uEuclidnorm); plt.title("Heat") # Plot norm of velocity
        if t == 0.: plt.colorbar(); plt.axis(G)
        plt.subplot(1, 2, 2);
        if t == 0.: plt.triplot(mesh2triang(mesh)); plt.title("Mesh") # Plot mesh
        plt.suptitle("Heat - t: %f" % (t)); plt.tight_layout(); clear_output(wait=True);    
开发者ID:xunilrj,项目名称:sandbox,代码行数:8,代码来源:heat.py


示例18: triangulate

def triangulate(n):
    X = np.linspace(0,1,n)
    Y = X.copy()
    X,Y = np.meshgrid(X,Y,copy=False)
    A = np.column_stack((X.flat,Y.flat))
    D = st.Delaunay(A)
    plt.triplot(A[:,0],A[:,1],D.simplices.copy())
    plt.show()
开发者ID:KathleenF,项目名称:numerical_computing,代码行数:8,代码来源:voronoi_solutions.py


示例19: delaunay_triangulation

def delaunay_triangulation(points, plot=False):
    """ Extract a Delaunay's triangulation from the points """
    tri = Delaunay(points)
    if plot:
        plt.triplot(points[:, 0], points[:, 1], tri.simplices.copy())
        plt.plot(points[:, 0], points[:, 1], 'o')
        plt.show()
    return tri.simplices
开发者ID:fonfonx,项目名称:RSC_python,代码行数:8,代码来源:alignment.py


示例20: _render

    def _render(self, image_view=False, label=None, **kwargs):
        import matplotlib.pyplot as plt
        # Flip x and y for viewing if points are tied to an image
        points = self.points[:, ::-1] if image_view else self.points
        plt.triplot(points[:, 0], points[:, 1], self.trilist,
                    label=label, color='b')

        return self
开发者ID:ikassi,项目名称:menpo,代码行数:8,代码来源:viewmatplotlib.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyplot.twinx函数代码示例发布时间:2022-05-27
下一篇:
Python pyplot.tripcolor函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap