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


Python colorConverter.to_rgba函数代码示例

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


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

示例1: __init__

    def __init__(self, ax, data,labels=None, color_on='r', color_off='k'):
        self.axes = ax
        self.canvas = ax.figure.canvas
        self.data = data
        self.call_list = []

        self.Nxy = data.shape[0]
        self.color_on = colorConverter.to_rgba(color_on)
        self.color_off = colorConverter.to_rgba(color_off)

        facecolors = [self.color_on for _ in range(self.Nxy)]
        fig = ax.figure
        self.collection = RegularPolyCollection(
            fig.dpi, 6, sizes=(1,),
            facecolors=facecolors,
            edgecolors=facecolors,
            offsets = self.data,
            transOffset = ax.transData)

        ax.add_collection(self.collection, autolim=True)
        ax.autoscale_view()
        
        if labels is not None:
            ax.set_xlabel(labels[0])
            ax.set_ylabel(labels[1])
        self.cid = self.canvas.mpl_connect('button_press_event', self.onpress)
        self.ind = None
        self.canvas.draw()
开发者ID:belevtsoff,项目名称:SpikeSort,代码行数:28,代码来源:manual_sort.py

示例2: __init__

    def __init__(self, axis, **poly_kwargs):
        """
        Supply an axis on which to plot the boxes
        """
        self.ax = axis
        self.rois = []
        self.selector = None

        dflt_kwargs = dict(fc='#0000b3',
                           fa=0.25,
                           ec='k',
                           ea=1.0,
                           lw=1)

        dflt_kwargs.update(poly_kwargs)
        poly_kwargs = dflt_kwargs

        # Allow 'face_alpha' / 'fa' and 'edge_alpha' / 'ea'
        face_alpha = poly_kwargs.pop('fa', None)
        face_alpha = poly_kwargs.pop('face_alpha', face_alpha)

        face_color = poly_kwargs.pop('fc', None)
        face_color = poly_kwargs.pop('face_color', face_color)
        poly_kwargs['fc'] = colorConverter.to_rgba(face_color, alpha=face_alpha)

        edge_alpha = poly_kwargs.pop('ea', None)
        edge_alpha = poly_kwargs.pop('edge_alpha', edge_alpha)

        edge_color = poly_kwargs.pop('ec', None)
        edge_color = poly_kwargs.pop('edge_color', edge_color)
        poly_kwargs['ec'] = colorConverter.to_rgba(edge_color, alpha=edge_alpha)

        self.poly_kwargs = poly_kwargs
开发者ID:pganssle,项目名称:pyCEST,代码行数:33,代码来源:roi.py

示例3: show_window

    def show_window(self, subwindow):
        obstable_img = np.transpose(subwindow[0, :, :])
        alt_var_img = np.transpose(subwindow[1, :, :])

        # generate the colors for your colormap

        color1 = colorConverter.to_rgba('white')
        color2 = colorConverter.to_rgba('blue')

        # make the colormaps
        cmap1 = mpl.colors.LinearSegmentedColormap.from_list('my_cmap', ['white', 'black'], 256)
        cmap2 = mpl.colors.LinearSegmentedColormap.from_list('my_cmap2', [color1, color2], 256)

        cmap2._init()  # create the _lut array, with rgba values

        # create your alpha array and fill the colormap with them.
        # here it is progressive, but you can create whathever you want
        alphas = np.linspace(0., 1.0, cmap2.N + 3)
        cmap2._lut[:, -1] = alphas

        plt.figure()
        img3 = plt.imshow(obstable_img, interpolation='none', vmin=0, vmax=1, cmap=cmap1, origin='lower')
        plt.hold(True)
        img2 = plt.imshow(alt_var_img, interpolation='none', vmin=0, vmax=1, cmap=cmap2, origin='lower')
        plt.colorbar()
        plt.hold(False)
        plt.show()
开发者ID:ewilkinson,项目名称:CS689_FinalProj,代码行数:27,代码来源:map.py

示例4: _plot_from_line

    def _plot_from_line(plot, suffix, line):
        """
        Plot lines in Chaco Plot object `plot` given MPL Line2D `line`.
        """
        xname = "lx_{0}".format(suffix)
        yname = "ly_{0}".format(suffix)
        plot.data.set_data(xname, line.get_xdata())
        plot.data.set_data(yname, line.get_ydata())

        ls = line.get_linestyle()
        if ls != "None":
            plot.plot(
                (xname, yname),
                line_style=line_trans.get(ls, "solid"),
                color=colorConverter.to_rgba(line.get_color()))

        marker = line.get_marker()
        if marker != "None":
            chaco_marker = marker_trans.get(marker, "circle")
            if chaco_marker == 'down triangle':
                # Workaround the bug in Chaco shell.
                # (https://github.com/enthought/chaco/issues/70)
                chaco_marker = 'inverted_triangle'
            plot.plot(
                (xname, yname),
                type="scatter",
                marker=chaco_marker,
                color=colorConverter.to_rgba(line.get_markerfacecolor()))
开发者ID:tkf,项目名称:mplchaco,代码行数:28,代码来源:__init__.py

示例5: plot_band

def plot_band(obj=None, step=False, emptybins=True, ax=None, **kwargs):
    """ Produce an errorbar plots with or without connecting lines.

    Args:
        obj: Mplobj representation of a root object.
        ax: Axis to plot on. If not specified current global axis will be used.
        x_err: If True, x errorbars will be plotted.
        yerr: If True, y errorbars will be plotted.
        emptybins: Not Implemented. Supposed to ignore/plot empty bins.
    """
    # Convert root object to mpl readable object
    obj = R2npObject1D(obj)
    # if no axis passed use current global axis
    if ax is None:
        ax = plt.gca()

    x = obj.x
    y = obj.y


    y_errl = obj.yerrl
    y_erru = obj.yerru

    if step:
        x = steppify_bin(obj.xbinedges, isx=True)
        y = steppify_bin(y)
        y_errl = steppify_bin(y_errl)
        y_erru = steppify_bin(y_erru)

    y_le = y - y_errl
    y_ue = y + y_erru
    if 'clip_vals' in kwargs:
        y_le = np.clip(y - y_errl, kwargs['clip_vals'][0], kwargs['clip_vals'][1])
        y_ue = np.clip(y + y_erru, kwargs['clip_vals'][0], kwargs['clip_vals'][1])

    if kwargs['facecolor'] == 'none':
        fill = False
    else:
        fill = True

    kwargs['facecolor'] = colorConverter.to_rgba(kwargs['facecolor'], kwargs.get('alpha', 1.0))
    kwargs['edgecolor'] = colorConverter.to_rgba(kwargs['edgecolor'], kwargs.get('edgealpha', 1.0))

    # plot without hatch
    fill_between_kwargs = {k: v for k, v in kwargs.items() if
                           k in ['label', 'facecolor', 'edgecolor', 'zorder', 'rasterized', 'linewidth']}

    artist = ax.fill_between(x, y_le, y_ue, **fill_between_kwargs)

    # work around okular bug present when hatch+color is plotted (plot 
    if 'hatch' in kwargs:
        fill_between_kwargs2 = {k: v for k, v in kwargs.items() if
                               k in ['label', 'edgecolor', 'zorder', 'hatch', 'rasterized', 'linewidth']}
        artist = ax.fill_between(x, y_le, y_ue, color='none', **fill_between_kwargs2)

    p = matplotlib.patches.Rectangle((0, 0), 0, 0, hatch=kwargs.get('hatch', ''), **fill_between_kwargs)
    ax.add_patch(p)

    return p
开发者ID:claria,项目名称:plot,代码行数:59,代码来源:plot_tools.py

示例6: color

 def color(value):
     """
     A valid matplotlib color
     """
     from matplotlib.colors import colorConverter
     try:
         colorConverter.to_rgba(value)
     except ValueError:
         return False
开发者ID:PennyQ,项目名称:glue,代码行数:9,代码来源:contracts.py

示例7: draw3DComplex

def draw3DComplex(K, axes, dimensions = [0,1,2,3]):
	if isinstance(K, CH.CubicalComplex):
		if 0 in dimensions:
			points = [map(lambda x:x[0], cube.intervals) for cube in K(0) if not K.isCritical(cube)]
			if points:
				x, y, z = map(np.array, zip(*points))
				axes.scatter(y, z, -x, c='b', marker='o')
			criticalPoints = [map(lambda x:x[0], cube.intervals) for cube in K(0) if K.isCritical(cube)]
			if criticalPoints:
				x, y, z = map(np.array, zip(*criticalPoints))
				axes.scatter(y, z, -x, c='r', marker='o')
			
		r1 = 0.85
		r3 = 0.8
		a1 = 0.9
		a2 = 0.8

		if 1 in dimensions:
			for edge in K(1):
				c = 'g-' if K.isCritical(edge) else 'b--'
				points = list(product(*map(set, edge.intervals)))
				V = [homothetic(edge.center, r1, P) for P in points]
				x, y, z = map(np.array, zip(*V))
				axes.plot(y, z, -x, c, linewidth=2, )

		if 2 in dimensions:
			for face in K(2):
				points = list(product(*map(set, face.intervals)))
				V = [homothetic(face.center, r1, P) for P in points]
				x, y, z = map(np.array, zip(*V))
				X, Y, Z = map(lambda x: x.copy(), [x, y, z])
				X[2], X[3] = x[3], x[2]
				Y[2], Y[3] = y[3], y[2]
				Z[2], Z[3] = z[3], z[2]
				poly = Poly3DCollection(
					[zip(Y, Z, -X)], 
					facecolor=colorConverter.to_rgba('g', a2))
				axes.add_collection3d(poly)

		if 3 in dimensions:
			for cube in K(3):
				for face in cube.border():
					points = list(product(*map(set, face.intervals)))
					V = [homothetic(cube.center, r3, P) for P in points]
					x, y, z = map(np.array, zip(*V))
					X, Y, Z = map(lambda x: x.copy(), [x, y, z])
					X[2], X[3] = x[3], x[2]
					Y[2], Y[3] = y[3], y[2]
					Z[2], Z[3] = z[3], z[2]
					poly = Poly3DCollection(
						[zip(Y, Z, -X)], 
						facecolor=colorConverter.to_rgba('r', 1))
					axes.add_collection3d(poly)
	elif isinstance(K, ACH.CubicalComplex):
		draw3DComplex(K.toCubicalComplex(), axes, dimension)		
开发者ID:raulrm75,项目名称:MC_thinning,代码行数:55,代码来源:Draw3DCubicalComplex.py

示例8: export_color

def export_color(color):
    """Convert matplotlib color code to hex color or RGBA color"""
    if color is None or colorConverter.to_rgba(color)[3] == 0:
        return 'none'
    elif colorConverter.to_rgba(color)[3] == 1:
        rgb = colorConverter.to_rgb(color)
        return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb))
    else:
        c = colorConverter.to_rgba(color)
        return "rgba(" + ", ".join(str(int(np.round(val * 255)))
                                        for val in c[:3])+', '+str(c[3])+")"
开发者ID:codybushnell,项目名称:plotly.py,代码行数:11,代码来源:utils.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: 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

示例11: _shade_colors

    def _shade_colors(self, color, normals):
        """
        Shade *color* using normal vectors given by *normals*.
        *color* can also be an array of the same length as *normals*.
        """

        shade = []
        for n in normals:
            n = n / proj3d.mod(n)
            shade.append(np.dot(n, [-1, -1, 0.5]))

        shade = np.array(shade)
        mask = ~np.isnan(shade)

        if len(shade[mask]) > 0:
            norm = Normalize(min(shade[mask]), max(shade[mask]))
            if art3d.iscolor(color):
                color = color.copy()
                color[3] = 1
                colors = [color * (0.5 + norm(v) * 0.5) for v in shade]
            else:
                colors = [np.array(colorConverter.to_rgba(c)) * (0.5 + norm(v) * 0.5) for c, v in zip(color, shade)]
        else:
            colors = color.copy()

        return colors
开发者ID:ranjithtenz,项目名称:cis530,代码行数:26,代码来源:axes3d.py

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

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

示例14: doTracelines

def doTracelines(xstart,ystart,zstart,step,tmax,Nmax):
    global ActiveAxis, ActiveCanvas, ActiveTimmlModel, ActiveSettings
    setActiveWindow()
    win = getActiveWindow()
    ActiveAxis.set_autoscale_on(False)
    width = 0.5
    color = []
    for j in range(getActiveNumberLayers()):
        color.append( ActiveSettings.get_color('Trace',j) )
        color[j] = colorConverter.to_rgba( color[j] )
    for i in range( len(xstart) ):
        xyz, time, reason, pylayers = ActiveTimmlModel.\
            traceline(xstart[i],ystart[i],zstart[i],step,tmax,Nmax,tstart=0.0,window=win,labfrac = 2.0, Hfrac = 2.0)
        trace_color = []
        for j in range(len(xyz)-1):  # Number of segments one less than number of points
            trace_color.append( color[ pylayers[j] ] )
        points = zip( xyz[:,0], xyz[:,1] )
        segments = zip( points[:-1], points[1:] )
        LC = LineCollection(segments, colors = trace_color)
        LC.set_linewidth(width)
        ActiveAxis.add_collection(LC)
        #ActiveAxis.plot( xyz[:,0], xyz[:,1], 'b' )
    ActiveAxis.set_xlim(win[0],win[2])
    ActiveAxis.set_ylim(win[1],win[3])
    ActiveCanvas.draw()
开发者ID:kmcoulib,项目名称:timml,代码行数:25,代码来源:TimMLgui.py

示例15: set_data

 def set_data(self, zname, zdata, zcolor):
     if zdata!=None:
         if self.overall_plot_type=="polygon":
            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)
         if self.overall_plot_type=="XY":
             if zname not in self.clts:
                 clt = LineCollection(zdata)#, offsets=offs)
                 clt.set_color(colors)
                 #print dir(clt)
                 self.clts[zname]=clt
                 self.axe.add_collection(self.clts[zname], autolim=True)
                 self.axe.autoscale_view()
             else:
                 self.clts[zname].set_segments(zdata)
         if self.overall_plot_type=="img":
             if zname not in self.clts:
                 axeimg=self.axe.imshow( Magvec, 
                                        vmin=amin(Magvec),
                                        vmax=0.001, #amax(Magvec), 
                                        aspect="auto", origin="lower",
                                 extent=[amin(yoko),amax(yoko), amin(freq),amax(freq)],
                                 #cmap='RdBu'
                                 )
                 self.fig.colorbar(axeimg)
开发者ID:priyanka27s,项目名称:TA_software,代码行数:30,代码来源:a_Plotter.py


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