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

Python collections.PolyCollection类代码示例

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

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



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

示例1: funDisplayDifferenceCurveIn3D

def funDisplayDifferenceCurveIn3D(vecDigitLevel, inputData_x, dataToDisplay_y, xLabelText, yLabelText, zLabelText, titleText, figureName):
    '''
    Exactly the same as the function above, but in 3D, yes in 3D, it is the future here.
    '''
    fig = plt.figure()
    ax = fig.gca(projection='3d')

    cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.2)

    xs = inputData_x
    verts = []
    tabColor = []
    zs = vecDigitLevel
    for ii in np.arange(0,np.size(vecDigitLevel)):
        ys = dataToDisplay_y[ii,:]    
        ys[0], ys[-1] = 0, 0  
        verts.append(list(zip(xs, ys)))
        tabColor.append(list(cc(repr(vecDigitLevel[ii]/255.))))

    poly = PolyCollection(verts, facecolors = tabColor)
    poly.set_alpha(0.7)

    ax.add_collection3d(poly, zs=zs, zdir='y')
    ax.set_xlabel(xLabelText)#'level search')
    ax.set_xlim3d(0, 255)
    ax.set_ylabel(yLabelText)#'level tested')
    ax.set_ylim3d(-1, 256)
    ax.set_zlabel(zLabelText)#L difference')
    ax.set_zlim3d(0, 1)
    plt.title(titleText)#'Various difference curves in 3D')
    plt.draw()
    plt.savefig(figureName)# dirToSaveResults+prefixName+'_c1_2.png')
开发者ID:mrbonsoir,项目名称:devForWebCam,代码行数:32,代码来源:scriptComputeResponseCurveWithWebcam.py


示例2: init

    def init(self, view):

        cube_points = np.arange(0, 10, 0.4)
        verts = []

        # number of polygons
        figures_num = [0.0, 1.0, 2.0, 3.0]

        for z in figures_num:
            ys = np.random.rand(len(cube_points))
            ys[0], ys[-1] = 0, 0
            verts.append(list(zip(cube_points, ys)))

            
        poly = PolyCollection(verts, facecolors=[self.convert_color('r'), self.convert_color('g'), self.convert_color('b'),
                                                 self.convert_color('y')])
        poly.set_alpha(0.7)
        self.ax.add_collection3d(poly, zs=figures_num, zdir='y')

        self.ax.set_xlabel('X')
        self.ax.set_xlim3d(0, 10)
        self.ax.set_ylabel('Y')
        self.ax.set_ylim3d(-1, 4)
        self.ax.set_zlabel('Z')
        self.ax.set_zlim3d(0, 1)

        if view == "image":
            savefig('polygon.png')
            print "Image saved on tredify folder"
        else:
            plt.show()
开发者ID:gsalvatori,项目名称:tredify,代码行数:31,代码来源:Polygon.py


示例3: __init__

	def __init__(self, start_ls, end_ls, y=0, width=0.001, x_offset=0, is_arrow=True, length_includes_head=True, \
		head_width=None, head_length=None, shape='full', overhang=0, \
		head_starts_at_zero=False,**kwargs):
		if head_width is None:
			head_width = 2 * width
		if head_length is None:
			head_length = 1/(2.0 * abs(end_ls[0]-start_ls[0]))

		distance = abs(end_ls[-1]-start_ls[0])
		if length_includes_head:
			length=distance
		else:
			length=distance+head_length
		
		no_of_blocks = len(start_ls)
		if not distance:
			verts_ls = [] #display nothing if empty
		else:
			"""
			start by drawing horizontal arrow, point (tip of the arrow) at (0,0). the whole arrow sticks on the x-axis (<=0 part)
			Notice: the XY -coordination is not the usual math coordination system. it's canvas coordination. (0,0) is top left. horizontal is y-axis. vertical is x-axis.
			start from the last block, reversely to the 1st block
			"""
			verts_ls = []
			for i in range(no_of_blocks):
				block_start = start_ls[i]
				block_end = end_ls[i]
				verts = [[block_start, width/2.0+y], [block_start, -width/2.0+y], [block_end, -width/2.0+y], [block_end, width/2.0+y]]
				
				verts_ls.append(verts)
		PolyCollection.__init__(self, verts_ls, **kwargs)
开发者ID:,项目名称:,代码行数:31,代码来源:


示例4: visualizeHealPixMap

def visualizeHealPixMap(theMap, nest=True, title="map", norm=None, vmin=None, vmax=None, cmap=plt.cm.hot_r):
    
    from matplotlib.collections import PolyCollection
    from matplotlib.colors import Normalize
    nside = hp.npix2nside(theMap.size)
    mapValue = theMap[theMap != hp.UNSEEN]
    indices = np.arange(theMap.size)
    seenInds = indices[theMap != hp.UNSEEN]

    print "Building polygons from HEALPixel map."
    vertices = np.zeros( (seenInds.size, 4, 2) )
    print "Building polygons for "+str(seenInds.size)+" HEALPixels."
    for HPixel,i in zip(seenInds,xrange(seenInds.size)):
        corners = hp.vec2ang( np.transpose(hp.boundaries(nside,HPixel,nest=nest) ) )
        # HEALPix insists on using theta/phi; we in astronomy like to use ra/dec.
        vertices[i,:,0] = corners[1] *180./np.pi
        vertices[i,:,1] = 90.0 - corners[0] * 180/np.pi


    fig, ax = plt.subplots(figsize=(12,12))
    #coll = PolyCollection(vertices, array = mapValue, cmap = plt.cm.seismic, edgecolors='none')
    coll = PolyCollection(vertices, array=mapValue, cmap=cmap, edgecolors='none')
    coll.set_clim(vmin=vmin, vmax=vmax)
    ax.add_collection(coll)
    ax.set_title(title)
    ax.autoscale_view()
    fig.colorbar(coll,ax=ax)

    #ax.set_ylim([-60.2, -43])

    print "Writing to file: "+title+".png"
    fig.savefig(title+".png",format="png")
开发者ID:suchyta1,项目名称:BalrogPaperScripts,代码行数:32,代码来源:mapfunc.py


示例5: plotPolyArrayFunction

    def plotPolyArrayFunction(self,result):
        interval = ((self.endValue - self.startValue) / (self.polyNumber - 1))
        self.rr.reset()
        fig = plt.figure()
        ax = fig.gca(projection='3d')
        if self.startValue is None:
            self.startValue = self.rr.model[self.value]
        columnNumber = self.polyNumber + 1
        lastPoint = [self.endTime]
        firstPoint = [self.startTime]
        for i in range(int(columnNumber) - 1):
            lastPoint.append(0)
            firstPoint.append(0)
        lastPoint = np.array(lastPoint)
        firstPoint = np.array(firstPoint)
        zresult = np.vstack((result, lastPoint))
        zresult = np.vstack((firstPoint, zresult))
        zs = []
        result = []
        for i in range(int(columnNumber) - 1):
            zs.append(i)
            result.append(zip(zresult[:, 0], zresult[:, (i + 1)]))
        if self.color is None:
            poly = PolyCollection(result)
        else:
            if len(self.color) != self.polyNumber:
                self.color = self.colorCycle()
            poly = PolyCollection(result, facecolors=self.color, closed=False)

        poly.set_alpha(self.alpha)
        ax.add_collection3d(poly, zs=zs, zdir='y')
        ax.set_xlim3d(0, self.endTime)
        ax.set_ylim3d(0, (columnNumber - 1))
        ax.set_zlim3d(0, (self.endValue + interval))
        if self.xlabel == 'toSet':
            ax.set_xlabel('Time')
        elif self.xlabel:
            ax.set_xlabel(self.xlabel)
        if self.ylabel == 'toSet':
            ax.set_ylabel('Trial Number')
        elif self.ylabel:
            ax.set_ylabel(self.ylabel)
        if self.zlabel == 'toSet':
            ax.set_zlabel(self.value)
        elif self.zlabel:
            ax.set_zlabel(self.zlabel)
            #        ax.set_xlabel('Time') if self.xlabel is None else ax.set_xlabel(self.xlabel)
            #        ax.set_ylabel('Trial Number') if self.ylabel is None else ax.set_ylabel(self.ylabel)
            #        ax.set_zlabel(self.value) if self.zlabel is None else ax.set_zlabel(self.zlabel)
        if self.title is not None:
            ax.set_title(self.title)
        
        if not IPYTHON:
            plt.show()
        else:
            FILENAME = str(uuid.uuid4()) + ".png"
            plt.savefig(FILENAME)
            plt.close()
            imag = mpimg.imread(FILENAME)
            return(imag)
开发者ID:kirichoi,项目名称:tellurium,代码行数:60,代码来源:parameterscan.py


示例6: plot_series

def plot_series(time, variable, series, ylabel='Y', zlabel='Z', fromzero=False):
    figure = plt.figure()
    ax = figure.gca(projection='3d')

    globalmin = np.min(map(lambda trial: np.min(trial), series))
    globalmax = np.max(map(lambda trial: np.max(trial), series))

    def stub(trial):
        if not fromzero:
            trial = map(lambda x: x - globalmin, np.array(trial))
            trial[0] = 0

        trial[-1] = 0
        return np.array(trial)

    verts = map(lambda trial: zip(time, stub(trial)), series)
    poly = PolyCollection(np.array(verts), facecolors=map(lambda n: cm.jet(n), np.linspace(0, 1, len(series))))
    poly.set_alpha(0.7)

    if not fromzero:
        globalmax -= globalmin
        globalmin -= globalmin

    ax.add_collection3d(poly, zs=variable, zdir='y')
    ax.set_xlim3d(time[0], time[-1])
    ax.set_ylim3d(min(variable), max(variable))
    ax.set_zlim3d(globalmin, globalmax)

    ax.set_xlabel('Time (ms)')
    ax.set_ylabel(ylabel)
    ax.set_zlabel(zlabel)
开发者ID:prismofeverything,项目名称:school,代码行数:31,代码来源:plot.py


示例7: poly3d

def poly3d(df, elev=0, azim=0, **pltkwds):
    ''' Written by evelyn, updated by Adam 12/1/12.'''

    xlabel, ylabel, title, pltkwds=pu.smart_label(df, pltkwds)    

    zlabel_def=''         
    zlabel=pltkwds.pop('zlabel', zlabel_def)   
    zs=df.columns

    verts=[zip(df.index, df[col]) for col in df]  #don't have to say df.columns
    
    fig = plt.figure()
    ax = fig.gca(projection='3d')
       
 ### Convert verts(type:list) to poly(type:mpl_toolkits.mplot3d.art3d.Poly3DCollection)  
 ### poly used in plotting function ax.add_collection3d to do polygon plot    
    cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
    poly = PolyCollection((verts), facecolors = [cc('b'), cc('g'), cc('r'),
                        cc('y'),cc('m'), cc('c'), cc('b'),cc('g'),cc('r'), cc('y')])
    poly.set_alpha(0.2)  
    
 ### zdir is the direction used to plot,here we use time so y axis
    ax.add_collection3d(poly, zs=zs, zdir='x')        
    ax.set_xlabel(xlabel) 
    ax.set_ylabel(ylabel)  #Y
    ax.set_zlabel(zlabel)   #data     
    ax.set_title(title)       

    ax.set_ylim3d(min(df.index), max(df.index))
    ax.set_xlim3d(min(df.columns), max(df.columns))    #x 
    ax.set_zlim3d(min(df.min()), max(df.max()))  #How to get absolute min/max of df values
    
    ax.view_init(elev, azim) 

    return ax
开发者ID:ZaighumRajput,项目名称:pyuvvis,代码行数:35,代码来源:advanced_plots.py


示例8: make_image

def make_image(x):
	''' x wil be a matrix data structure. '''
	fig = plt.figure()
	ax = fig.gca(projection='3d')
#
	cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
#
	xs = np.arange(0, 10, 0.4)
	verts = x.get_verts('freq')
	for i in xrange(17):
		print verts[0][i],'\n'
	for i in xrange(17):
		print verts[1][i],'\n'
	zs = [0.0, 1.0, 2.0, 3.0]
#	for z in zs:
#		ys = np.random.rand(len(xs))
#		ys[0], ys[-1] = 0, 0
#		verts.append(list(zip(xs, ys)))
#	poly = PolyCollection(verts, facecolors = [cc('r'), cc('g'), cc('b'),cc('y')])
	poly = PolyCollection(verts)
	poly.set_alpha(0.3)
#	ax.add_collection3d(poly, zs=zs, zdir='y')
	ax.add_collection3d(poly, zs=zs, zdir='y')
#
	ax.set_xlabel('X')
	ax.set_xlim3d(0, 123456)
	ax.set_ylabel('Y')
	ax.set_ylim3d(0, 65536)
	ax.set_zlabel('Z')
	ax.set_zlim3d(0, 1000)
#
	plt.show()
开发者ID:baallezx,项目名称:dsp,代码行数:32,代码来源:495_wav3.py


示例9: test_something

    def test_something(self):
        fig = plt.figure()
        ax = fig.gca(projection='3d')

        cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)

        xs = np.arange(0, 10, 0.4)
        verts = []
        zs = [0.0, 1.0, 2.0, 3.0]
        for z in zs:
            ys = np.random.rand(len(xs))
            ys[0], ys[-1] = 0, 0
            verts.append(list(zip(xs, ys)))

        poly = PolyCollection(verts, facecolors = [cc('r'), cc('g'), cc('b'),
                                                   cc('y')])
        poly.set_alpha(0.7)
        ax.add_collection3d(poly, zs=zs, zdir='y')

        ax.set_xlabel('Coordinate')
        ax.set_xlim3d(0, 10)
        ax.set_ylabel('hypothesis#')
        ax.set_ylim3d(-1, 4)
        ax.set_zlabel('Concentration')
        ax.set_zlim3d(0, 1)

        plt.show()
开发者ID:dtbinh,项目名称:Sniffer2,代码行数:27,代码来源:testPloys3D.py


示例10: plot4MainDir

def plot4MainDir(degVector):
    fourDirVector = allDeg24Directions(degVector['Value'])
    pHours = 24 # periodo considerado
    sampling = 60 # 10min de amostragem
    base = pHours*60/sampling
    totDays = len(fourDirVector)/base  # Dias multiplo de 5, para graficos poly 3d
    days  = np.arange(totDays)+1
    hours = np.arange(0,pHours*60,sampling)
    meshTime, indices = np.meshgrid(hours, days)
    meshProfile = np.zeros(meshTime.shape)
    profileList = []
    ii = 1
    for i in range(totDays):
        dataPeriod = fourDirVector[i*base:ii*base]
        profileList.append( dataPeriod )
        ii +=1
    profileMatrix = np.array(profileList)
    for i in range( indices.shape[0] ):
        for j in range( indices.shape[1] ):
            meshProfile[(i,j)] = profileMatrix[(i,j)]

    fig = plt.figure()
    ax = fig.gca(projection='3d')
    X = meshTime
    Y = indices
    Z = meshProfile
    ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='coolwarm', alpha=0.8) # ou a linha abaixo
    ax.set_xlabel('minutos')
    ax.set_ylabel('dia')
    ax.set_zlabel(r'$^oC$')

    # Visao apenas dos perfis
    fig2 = plt.figure()
    ax2 = fig2.gca(projection='3d')
    cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
    verts = []
    cs = [cc('r'), cc('g'), cc('b'), cc('y'), cc('c')]*(totDays/5)
    k = 0
    for d in days:
        verts.append(list(zip(hours, meshProfile[k])))
        k += 1
    poly = PolyCollection(verts, facecolors = cs)
    poly.set_alpha(0.7)
    ax2.add_collection3d(poly, zs=days, zdir='y')

    """ OK! Mostra grafico de barras
    cs = ['r', 'g', 'b', 'y','c']*(totDays/5)
    k = 0
    for c, d in zip(cs, days):
        cc = [c]*len(hours)
        ax2.bar(hours, meshProfile[k], zs=d, zdir='y', color=cc, alpha=0.5)
        k += 1
    """
    ax2.set_xlabel('minutos')
    ax2.set_xlim3d(0, hours[-1])
    ax2.set_ylabel('dia')
    ax2.set_ylim3d(0, days[-1])
    ax2.set_zlabel('Dir')
    ax2.set_zlim3d(0, 360)
    plt.show()
开发者ID:mauricio-elipse,项目名称:python,代码行数:60,代码来源:AerogeneratorDemo.py


示例11: draw

 def draw(self, renderer):
     self._init()
     if self._new_UV:
         verts = self._make_verts(self.U, self.V)
         self.set_verts(verts)
         self._new_UV = False
     PolyCollection.draw(self, renderer)
开发者ID:,项目名称:,代码行数:7,代码来源:


示例12: animate

def animate(p):
  global count, centers, angles, coords, skip, colors, histogram, success, angle_histogram
  mc()
  density = histogram/leny/dx/count
  xnew, density = make_square(xcoords, density)
  line.set_ydata(density)
  ang_vals = angle_histogram/count/pi
  ax3.collections = []
  angplot = ax3.pcolormesh(x, theta, ang_vals, vmin=0, vmax=.01, edgecolors='face', cmap=cm.hot_r)
  #angplot = ax3.contourf(x, theta, ang_vals, levels=arange(0, .0105, .001), extend="max", rasterized=True)
  cbar_ax.collections = []
  cs = fig.colorbar(angplot, cax=cbar_ax, ticks=[])
  cs.cmap.set_over('k')
  cs.set_clim([0, .01])
  ax2.set_ylim(0, 0.8)
  for i in xrange(n):
    coords[i] = verts(centers[i], angles[i])
  coll = PolyCollection(coords)

  colors = zeros(n) + cdefault
  colors[0] = cspecial
  coll.set_color([cm.jet(val) for val in colors])
  ax.collections=[]
  ax.add_collection(coll)
  ax.set_title("Attempted: %6i, Successful: %6i" %(count*n, success))
  #fig.tight_layout()
  print p
  return line, ax2, ax3
开发者ID:droundy,项目名称:deft,代码行数:28,代码来源:mc-tri.py


示例13: index_bar

def index_bar(ax, vals,
              facecolor='b', edgecolor='l',
              width=4, alpha=1.0, ):
    """
    Add a bar collection graph with height vals (-1 is missing).
    ax          : an Axes instance to plot to
    width       : the bar width in points
    alpha       : bar transparency
    """
    facecolors = (colorConverter.to_rgba(facecolor, alpha),)
    edgecolors = (colorConverter.to_rgba(edgecolor, alpha),)
    right = width/2.0
    left = -width/2.0
    bars = [ ( (left, 0), (left, v), (right, v), (right, 0)) for v in vals if v != -1 ]
    sx = ax.figure.dpi * (1.0/72.0)  # scale for points
    sy = ax.bbox.height / ax.viewLim.height
    barTransform = Affine2D().scale(sx,sy)
    offsetsBars = [ (i, 0) for i,v in enumerate(vals) if v != -1 ]
    barCollection = PolyCollection(bars,
                                   facecolors   = facecolors,
                                   edgecolors   = edgecolors,
                                   antialiaseds = (0,),
                                   linewidths   = (0.5,),
                                   offsets      = offsetsBars,
                                   transOffset  = ax.transData,
                                   )
    barCollection.set_transform(barTransform)
    minpy, maxx = (0, len(offsetsBars))
    miny = 0
    maxy = max([v for v in vals if v!=-1])
    corners = (minpy, miny), (maxx, maxy)
    ax.update_datalim(corners)
    ax.autoscale_view()
    ax.add_collection(barCollection)
    return barCollection
开发者ID:,项目名称:,代码行数:35,代码来源:


示例14: do_3d_projection

    def do_3d_projection(self, renderer):
        """
        Perform the 3D projection for this object.
        """
        # FIXME: This may no longer be needed?
        if self._A is not None:
            self.update_scalarmappable()
            self._facecolors3d = self._facecolors

        txs, tys, tzs = proj3d.proj_transform_vec(self._vec, renderer.M)
        xyzlist = [(txs[si:ei], tys[si:ei], tzs[si:ei])
                   for si, ei in self._segis]

        # This extra fuss is to re-order face / edge colors
        cface = self._facecolors3d
        cedge = self._edgecolors3d
        if len(cface) != len(xyzlist):
            cface = cface.repeat(len(xyzlist), axis=0)
        if len(cedge) != len(xyzlist):
            if len(cedge) == 0:
                cedge = cface
            else:
                cedge = cedge.repeat(len(xyzlist), axis=0)

        # if required sort by depth (furthest drawn first)
        if self._zsort:
            z_segments_2d = sorted(
                ((self._zsortfunc(zs), np.column_stack([xs, ys]), fc, ec, idx)
                 for idx, ((xs, ys, zs), fc, ec)
                 in enumerate(zip(xyzlist, cface, cedge))),
                key=lambda x: x[0], reverse=True)
        else:
            raise ValueError("whoops")

        segments_2d = [s for z, s, fc, ec, idx in z_segments_2d]
        if self._codes3d is not None:
            codes = [self._codes3d[idx] for z, s, fc, ec, idx in z_segments_2d]
            PolyCollection.set_verts_and_codes(self, segments_2d, codes)
        else:
            PolyCollection.set_verts(self, segments_2d, self._closed)

        self._facecolors2d = [fc for z, s, fc, ec, idx in z_segments_2d]
        if len(self._edgecolors3d) == len(cface):
            self._edgecolors2d = [ec for z, s, fc, ec, idx in z_segments_2d]
        else:
            self._edgecolors2d = self._edgecolors3d

        # Return zorder value
        if self._sort_zpos is not None:
            zvec = np.array([[0], [0], [self._sort_zpos], [1]])
            ztrans = proj3d.proj_transform_vec(zvec, renderer.M)
            return ztrans[2][0]
        elif tzs.size > 0 :
            # FIXME: Some results still don't look quite right.
            #        In particular, examine contourf3d_demo2.py
            #        with az = -54 and elev = -45.
            return np.min(tzs)
        else :
            return np.nan
开发者ID:magnunor,项目名称:matplotlib,代码行数:59,代码来源:art3d.py


示例15: set_3d_properties

 def set_3d_properties(self):
     # Force the collection to initialize the face and edgecolors
     # just in case it is a scalarmappable with a colormap.
     self.update_scalarmappable()
     self._sort_zpos = None
     self.set_zsort(True)
     self._facecolors3d = PolyCollection.get_facecolors(self)
     self._edgecolors3d = PolyCollection.get_edgecolors(self)
开发者ID:Aharobot,项目名称:matplotlib,代码行数:8,代码来源:art3d.py


示例16: multidraw

def multidraw(courbesA,courbesB):

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

    verts = []
    facecolor=[]
    for lacourbe in courbesA:
        xs=[]
        closepoly=[]
        for idx,X in enumerate(lacourbe):
            xs.append(idx)
            closepoly.append(0)
            xs.append(idx)
            closepoly.append(X)
            xs.append(idx+.3)
            closepoly.append(X)
            xs.append(idx+.3)
            closepoly.append(0)
        xs.append(0)
        closepoly.append(0)
            
        verts.append(list(zip(xs, closepoly)))
        facecolor.append(cc('b'))

    for lacourbe in courbesB:
        xs=[]
        closepoly=[]
        for idx,X in enumerate(lacourbe):
            xs.append(idx)
            closepoly.append(0)
            xs.append(idx)
            closepoly.append(X)
            xs.append(idx+.3)
            closepoly.append(X)
            xs.append(idx+.3)
            closepoly.append(0)
        xs.append(0)
        closepoly.append(0)
        
        verts.append(list(zip(xs, closepoly)))
        facecolor.append(cc('y'))
    
    print len(facecolor) ,len(verts)
     
    poly = PolyCollection(verts, facecolors=facecolor)
    zs = range(0,len(facecolor))
    poly.set_alpha(0.7)
    ax.add_collection3d(poly, zs=zs, zdir='y')
    
    ax.set_xlabel('X')
    ax.set_xlim3d(0,5)
    ax.set_ylabel('Y')
    ax.set_ylim3d(-1, len(verts))
    ax.set_zlabel('Z')
    ax.set_zlim3d(-3, 3)

    plt.show()
开发者ID:jonpolbob,项目名称:jupyter,代码行数:58,代码来源:svn-05.py


示例17: set_data

 def set_data(self, zname, zdata, zcolor):
     if zdata!=None:
        if zname not in self.clts: #plottables['plotted']:#self.pd.list_data():
            clt=PolyCollection(zdata, alpha=0.5, antialiased=True)#, rasterized=False, antialiased=False)
            clt.set_color(colorConverter.to_rgba(zcolor))                
            self.clts[zname]=clt
            self.axe.add_collection(self.clts[zname], autolim=True)
        else:                
            self.clts[zname].set_verts(zdata)
开发者ID:priyanka27s,项目名称:TA_software,代码行数:9,代码来源:Plotter_old.py


示例18: plotPolyArray

    def plotPolyArray(self):
        """Plots results as individual graphs parallel to each other in 3D space using results
        from graduatedSim().

        p.plotPolyArray()"""
        result = self.graduatedSim()
        interval = (self.endValue - self.startValue) / (self.polyNumber - 1)
        self.rr.reset()
        fig = plt.figure()
        ax = fig.gca(projection="3d")
        if self.startValue is None:
            self.startValue = self.rr.model[self.value]
        columnNumber = self.polyNumber + 1
        lastPoint = [self.endTime]
        firstPoint = [self.startTime]
        for i in range(int(columnNumber) - 1):
            lastPoint.append(0)
            firstPoint.append(0)
        lastPoint = np.array(lastPoint)
        firstPoint = np.array(firstPoint)
        zresult = np.vstack((result, lastPoint))
        zresult = np.vstack((firstPoint, zresult))
        zs = []
        result = []
        for i in range(int(columnNumber) - 1):
            zs.append(i)
            result.append(zip(zresult[:, 0], zresult[:, (i + 1)]))
        if self.color is None:
            poly = PolyCollection(result)
        else:
            if len(self.color) != self.polyNumber:
                self.color = self.colorCycle()
            poly = PolyCollection(result, facecolors=self.color, closed=False)

        poly.set_alpha(self.alpha)
        ax.add_collection3d(poly, zs=zs, zdir="y")
        ax.set_xlim3d(0, self.endTime)
        ax.set_ylim3d(0, (columnNumber - 1))
        ax.set_zlim3d(0, (self.endValue + interval))
        if self.xlabel == "toSet":
            ax.set_xlabel("Time")
        elif self.xlabel:
            ax.set_xlabel(self.xlabel)
        if self.ylabel == "toSet":
            ax.set_ylabel("Trial Number")
        elif self.ylabel:
            ax.set_ylabel(self.ylabel)
        if self.zlabel == "toSet":
            ax.set_zlabel(self.value)
        elif self.zlabel:
            ax.set_zlabel(self.zlabel)
        #        ax.set_xlabel('Time') if self.xlabel is None else ax.set_xlabel(self.xlabel)
        #        ax.set_ylabel('Trial Number') if self.ylabel is None else ax.set_ylabel(self.ylabel)
        #        ax.set_zlabel(self.value) if self.zlabel is None else ax.set_zlabel(self.zlabel)
        if self.title is not None:
            ax.set_title(self.title)
        plt.show()
开发者ID:matthiaskoenig,项目名称:tellurium,代码行数:57,代码来源:ParameterScan.py


示例19: poly_plot

 def poly_plot(self, zname, zdata, zcolor=None):
     if zname not in self.clts:
         clt=PolyCollection(zdata, alpha=0.5, antialiased=True)
         if zcolor is not None:
             clt.set_color(zcolor) #colorConverter.to_rgba(zcolor))
         self.clts[zname]=clt
         self.axe.add_collection(self.clts[zname])
     else:
         self.clts[zname].set_verts(zdata)
开发者ID:priyanka27s,项目名称:TA_software,代码行数:9,代码来源:Plotter.py


示例20: map_poly_shp

def map_poly_shp(shp, which='all', bbox=None):
    '''
    Create a map object from a polygon shape
    ...

    Arguments
    ---------

    shp             : iterable
                      PySAL polygon iterable (e.g.
                      shape object from `ps.open` a poly shapefile) If it does
                      not contain the attribute `bbox`, it must be passed
                      separately in `bbox`.
    which           : str/list
                      List of booleans for which polygons of the shapefile to
                      be included (True) or excluded (False)
    bbox            : None/list
                      [Optional. Default=None] List with bounding box as in a
                      PySAL object. If nothing is passed, it tries to obtain
                      it as an attribute from `shp`.

    Returns
    -------

    map             : PatchCollection
                      Map object with the polygons from the shape
                      This includes the attribute `shp2dbf_row` with the
                      cardinality of every polygon to its row in the dbf
                      (zero-offset)

    '''
    if not bbox:
        bbox = shp.bbox
    patches = []
    rows = []
    i = 0
    if which == 'all':
        for shape in shp:
            for ring in shape.parts:
                xy = np.array(ring)
                patches.append(xy)
                rows.append(i)
            i += 1
    else:
        for inwhich, shape in zip(which, shp):
            if inwhich:
                for ring in shape.parts:
                    xy = np.array(ring)
                    patches.append(xy)
                    rows.append(i)
                i += 1
    pc = PolyCollection(patches)
    _ = _add_axes2col(pc, bbox)
    pc.shp2dbf_row = rows
    return pc
开发者ID:amirneto,项目名称:pysal,代码行数:55,代码来源:mapping.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python collections.RegularPolyCollection类代码示例发布时间:2022-05-27
下一篇:
Python collections.PatchCollection类代码示例发布时间: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