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


Python colorConverter.to_rgba方法代码示例

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


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

示例1: export_color

# 需要导入模块: from matplotlib.colors import colorConverter [as 别名]
# 或者: from matplotlib.colors.colorConverter import to_rgba [as 别名]
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:mpld3,项目名称:mplexporter,代码行数:13,代码来源:utils.py

示例2: __init__

# 需要导入模块: from matplotlib.colors import colorConverter [as 别名]
# 或者: from matplotlib.colors.colorConverter import to_rgba [as 别名]
def __init__(self, offset=(2,-2),
                 shadow_color='k', alpha=0.3, rho=0.3, **kwargs):
        """
        Parameters
        ----------
        offset : pair of floats
            The offset to apply to the path, in points.
        shadow_color : color
            The shadow color. Default is black.
            A value of ``None`` takes the original artist's color
            with a scale factor of `rho`.
        alpha : float
            The alpha transparency of the created shadow patch.
            Default is 0.3.
        rho : float
            A scale factor to apply to the rgbFace color if `shadow_rgbFace`
            is ``None``. Default is 0.3.
        **kwargs
            Extra keywords are stored and passed through to
            :meth:`AbstractPathEffect._update_gc`.

        """
        super(SimpleLineShadow, self).__init__(offset)
        if shadow_color is None:
            self._shadow_color = shadow_color
        else:
            self._shadow_color = colorConverter.to_rgba(shadow_color)
        self._alpha = alpha
        self._rho = rho

        #: The dictionary of keywords to update the graphics collection with.
        self._gc = kwargs

        #: The offset transform object. The offset isn't calculated yet
        #: as we don't know how big the figure will be in pixels.
        self._offset_tran = mtransforms.Affine2D() 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:38,代码来源:patheffects.py

示例3: plot_weights

# 需要导入模块: from matplotlib.colors import colorConverter [as 别名]
# 或者: from matplotlib.colors.colorConverter import to_rgba [as 别名]
def plot_weights(weights_list, title="Neurons weights progress", y_lim = None):

    # Plot
    # Make a list of colors cycling through the rgbcmyk series.
    colors = [colorConverter.to_rgba(c) for c in ('k', 'r', 'g', 'b', 'c', 'y', 'm')]

    axes = pl.axes()
    ax4 = axes # unpack the axes

    ncurves = 1
    offs = (0.0, 0.0)

    segs = []
    for i in range(ncurves):
        curve = weights_list
        segs.append(curve)

    col = collections.LineCollection(segs, offsets=offs)
    ax4.add_collection(col, autolim=True)
    col.set_color(colors)
    ax4.autoscale_view()
    ax4.set_title(title)
    ax4.set_xlabel('Time ms')
    ax4.set_ylabel('Weight pA')
    y_lim = 105.
    if y_lim :
        ax4.set_ylim(-5, y_lim)
    pl.savefig(f_name_gen('dopa-weights', is_image=True), format='png')
    # pl.show()

# =======
# DEVICES
# ======= 
开发者ID:research-team,项目名称:NEUCOGAR,代码行数:35,代码来源:parameters_2.py

示例4: plot_weights

# 需要导入模块: from matplotlib.colors import colorConverter [as 别名]
# 或者: from matplotlib.colors.colorConverter import to_rgba [as 别名]
def plot_weights(weights_list, title="Neurons weights progress"):
    # Make a list of colors cycling through the rgbcmyk series.
    colors = [colorConverter.to_rgba(c) for c in ('k', 'r', 'g', 'b', 'c', 'y', 'm')]
    axes = pl.axes()
    ax4 = axes  # unpack the axes
    ncurves = 1
    offs = (0.0, 0.0)
    segs = []
    for i in range(ncurves):
        curve = weights_list
        segs.append(curve)

    col = collections.LineCollection(segs, offsets=offs)
    ax4.add_collection(col, autolim=True)
    col.set_color(colors)
    ax4.autoscale_view()
    ax4.set_title(title)
    ax4.set_xlabel('Time ms')
    ax4.set_ylabel('Weight pA')
    y_lim = 105.
    if y_lim:
        ax4.set_ylim(-5, y_lim)
    pl.savefig(f_name_gen('dopa-weights', is_image=True), format='png')
    # pl.show()

# =======
# DEVICES
# ======= 
开发者ID:research-team,项目名称:NEUCOGAR,代码行数:30,代码来源:parameters.py

示例5: color_to_hex

# 需要导入模块: from matplotlib.colors import colorConverter [as 别名]
# 或者: from matplotlib.colors.colorConverter import to_rgba [as 别名]
def color_to_hex(color):
    """Convert matplotlib color code to hex color code"""
    if color is None or colorConverter.to_rgba(color)[3] == 0:
        return 'none'
    else:
        rgb = colorConverter.to_rgb(color)
        return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb)) 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:9,代码来源:utils.py

示例6: index_bar

# 需要导入模块: from matplotlib.colors import colorConverter [as 别名]
# 或者: from matplotlib.colors.colorConverter import to_rgba [as 别名]
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()

    # add these last
    ax.add_collection(barCollection)
    return barCollection 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:56,代码来源:finance.py


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