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


Python PolyCollection.set_alpha方法代码示例

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


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

示例1: funDisplayDifferenceCurveIn3D

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
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,代码行数:34,代码来源:scriptComputeResponseCurveWithWebcam.py

示例2: init

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
    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,代码行数:33,代码来源:Polygon.py

示例3: test_something

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
    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,代码行数:29,代码来源:testPloys3D.py

示例4: plotPolyArrayFunction

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
    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,代码行数:62,代码来源:parameterscan.py

示例5: plot_series

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
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,代码行数:33,代码来源:plot.py

示例6: plot4MainDir

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
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,代码行数:62,代码来源:AerogeneratorDemo.py

示例7: make_image

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
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,代码行数:34,代码来源:495_wav3.py

示例8: poly3d

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
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,代码行数:37,代码来源:advanced_plots.py

示例9: multidraw

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
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,代码行数:60,代码来源:svn-05.py

示例10: plotPolyArray

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
    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,代码行数:59,代码来源:ParameterScan.py

示例11: redraw

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
    def redraw(self):
        self._canvas.axes.grid(True, color='gray')
        # Set axis bounds
        ymin = ymax = None
        xmax = 0
        xmin = sys.maxint
        for curve in self._curves.values():
            data_x, _, _, range_y, c = curve
            if len(data_x) == 0:
                continue
            xmax = max(xmax, data_x[-1])
            xmin = min(xmin, data_x[0])
            if ymin is None:
                ymin = range_y[0]
                ymax = range_y[1]
            else:
                ymin = min(range_y[0], ymin)
                ymax = max(range_y[1], ymax)

            # pad the min/max
            # delta = max(ymax - ymin, 0.1)
            # ymin -= .05 * delta
            # ymax += .05 * delta

        if self._autoscroll and ymin is not None:
            self._canvas.axes.set_xbound(lower=xmin, upper=xmax)
            self._canvas.axes.set_zbound(lower=ymin, upper=ymax)
            self._canvas.axes.set_ybound(lower=0,
                                         upper=len(self._curves.keys()))
        # create poly object
        verts = []
        colors = []
        for curve_id in self._curves_verts.keys():
            (data_x, data_y) = self._curves_verts[curve_id]
            colors.append(self._curves[curve_id][4])
            if self._use_poly:
                verts.append([(xmin, ymin)] + list(zip(data_x, data_y))
                             + [(xmax, ymin)])
            else:
                verts.append(zip(data_x, data_y))
        line_num = len(self._curves.keys())
        if self._use_poly:
            poly = PolyCollection(verts, facecolors=colors, closed=False)
        else:
            poly = LineCollection(verts, colors=colors)
        poly.set_alpha(0.7)
        self._canvas.axes.cla()
        self._canvas.axes.add_collection3d(poly,
                                           zs=range(line_num), zdir='y')
        self._update_legend()
        self._canvas.draw()
开发者ID:AtsushiSakai,项目名称:jsk_visualization,代码行数:53,代码来源:plot.py

示例12: plot_energy_3d

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
def plot_energy_3d(name, key_steps=50, filename=None):

    data = np.loadtxt('%s_energy.ndt' % name)

    if data.ndim == 1:
        data.shape = (1, -1)

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

    # image index
    xs = range(1, data.shape[1])

    steps = data[:, 0]

    each_n_step = int(len(steps) / key_steps)

    if each_n_step < 1:
        each_n_step = 1

    cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
    colors = [cc('r'), cc('g'), cc('b'), cc('y')]
    facecolors = []
    line_data = []
    energy_min = np.min(data[:, 1:])

    zs = []
    index = 0
    for i in range(0, len(steps), each_n_step):
        line_data.append(list(zip(xs, data[i, 1:] - energy_min)))
        facecolors.append(colors[index % 4])
        zs.append(data[i, 0])
        index += 1

    poly = PolyCollection(line_data, facecolors=facecolors, closed=False)
    poly.set_alpha(0.7)

    ax.add_collection3d(poly, zs=zs, zdir='x')

    ax.set_xlabel('Steps')
    ax.set_ylabel('images')
    ax.set_zlabel('Energy (J)')

    ax.set_ylim3d(0, len(xs) + 1)
    ax.set_xlim3d(0, int(data[-1, 0]) + 1)
    ax.set_zlim3d(0, np.max(data[:, 1:] - energy_min))

    if filename is None:
        filename = '%s_energy_3d.pdf' % name

    fig.savefig(filename)
开发者ID:computationalmodelling,项目名称:fidimag,代码行数:53,代码来源:helper.py

示例13: _waveform_3d

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
    def _waveform_3d(self, fig_type, zmin, zmax, alpha, cmap):
        fig = plt.figure(figsize=(10, 10))
        ax = fig.gca(projection='3d')

        num_times = self._inspector.num_times
        num_samples = self._inspector.num_samples
        if fig_type == 'surf':
            x = np.arange(0, num_samples)
            y = np.arange(0, num_times)
            x, y = np.meshgrid(x, y)
            z = self._inspector.waveform
            surf = ax.plot_surface(x, y, z, rstride=3, cstride=3, cmap=cmap, shade=True,
                                   linewidth=0, antialiased=False)
            # ax.zaxis.set_major_locator(LinearLocator(10))
            # ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
            fig.colorbar(surf, shrink=0.5, aspect=5)
        else:
            waveforms = []
            for y_index in range(num_times):
                waveform = np.ndarray(shape=(num_samples, 2), dtype=np.float64)
                waveform[:, 0] = np.arange(0, num_samples)
                waveform[:, 1] = self._inspector.waveform[y_index]
                waveforms.append(waveform)
            line_widths = [0.5] * num_times
            # TODO (forman, 20160725): check why cmap is not recognized
            if fig_type == 'poly':
                edge_colors = ((0.2, 0.2, 1., 0.7),) * num_times
                face_colors = ((1., 1., 1., 0.5),) * num_times
                collection = PolyCollection(waveforms, cmap=cmap,
                                            linewidths=line_widths,
                                            edgecolors=edge_colors,
                                            facecolors=face_colors)
            else:
                colors = ((0.2, 0.2, 1., 0.7),) * num_times
                collection = LineCollection(waveforms, cmap=cmap,
                                            linewidths=line_widths, colors=colors)
            collection.set_alpha(alpha)
            ax.add_collection3d(collection, zs=np.arange(0, num_times), zdir='y')

        wf_min, wf_max = self._inspector.waveform_range
        ax.set_xlabel('Echo Sample Index')
        ax.set_xlim3d(0, num_samples - 1)
        ax.set_ylabel('Time Index')
        ax.set_ylim3d(0, num_times - 1)
        ax.set_zlabel('Waveform')
        ax.set_zlim3d(zmin if zmin is not None else wf_min, zmax if zmax is not None else wf_max)

        if self._interactive:
            plt.show()
        else:
            self.savefig("fig-waveform-3d-%s.png" % fig_type)
开发者ID:DeDop,项目名称:dedop,代码行数:53,代码来源:inspect.py

示例14: plot_multiple_timeseries

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
def plot_multiple_timeseries(windpark, show=True):
    """Plot multiple power series of some turbines.

    Parameters
    ----------

    windpark : Windpark
               A given windpark to plot power series.
    """

    X = np.array(windpark.get_powermatrix())
    number_turbines = len(X[0])
    number_measurements = len(X)

    length = 100
    X = X[:length]

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

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

    def cc(arg):
        return colorConverter.to_rgba(arg, alpha=0.6)
    xs = range(1, number_measurements)
    verts = []
    zs = range(0, number_turbines)

    for z in zs:
        ys = X[:, z]
        ys[0], ys[-1] = 0, 0
        verts.append(list(zip(xs, ys)))

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

    ax.set_xlabel('Time')
    ax.set_xlim3d(0, length)
    ax.set_ylabel('Turbine')
    ax.set_ylim3d(-1, number_turbines)
    ax.set_zlabel('Power')
    ax.set_zlim3d(0, 30.)

    plt.title("Time Series Comparison")

    if show:
        plt.show()
开发者ID:cigroup-ol,项目名称:windml,代码行数:52,代码来源:plot_multiple_timeseries.py

示例15: plot_population

# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import set_alpha [as 别名]
def plot_population(ivp, depv_z_map):
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    verts=[]
    nt = 1000
    t = np.linspace(ivp.indepv_out()[0],
                    ivp.indepv_out()[-1], nt)
    n = len(depv_z_map)
    maxval = 0

    # Get interpolated (and back-transformed) results
    tm = time.time()
    for depv, x in depv_z_map.items():
	interpol = ivp.get_interpolated(t, [depv])
	# Let polygons be aligned with bottom
        # (important: choose nt large!)
	interpol[0,0] = 0.0
	interpol[0,-1] = 0.0
        # Check fo new max value:
	maxval = max(maxval, np.max(interpol))
	stacked = zip(t,interpol.reshape(nt))
        verts.append(stacked)#.transpose())
    print("Time of interpolation and back transformation: {}".format(
        time.time()-tm))

    # Generate plot
    tm = time.time()
    poly = PolyCollection(verts, facecolors = [
        'rgbk'[i%4] for i in range(len(verts))])
    poly.set_alpha(0.7)
    ax.add_collection3d(poly, zs=[
        x+1 for x in depv_z_map.values()], zdir='y')

    ax.set_xlabel('t')
    ax.set_xlim3d(0, t[-1])
    ax.set_ylabel('y')
    ax.set_ylim3d(0.5, n+0.5)
    ax.set_zlabel('z')
    ax.set_zlim3d(0, maxval)

    ya = ax.get_yaxis()
    ya.set_major_locator(MaxNLocator(integer=True))

    print ("Time of plot generation: {}".format(time.time()-tm))
    plt.show()
开发者ID:bjodah,项目名称:symodesys,代码行数:47,代码来源:birth_and_death.py


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