當前位置: 首頁>>代碼示例>>Python>>正文


Python colorConverter.to_rgb方法代碼示例

本文整理匯總了Python中matplotlib.colors.colorConverter.to_rgb方法的典型用法代碼示例。如果您正苦於以下問題:Python colorConverter.to_rgb方法的具體用法?Python colorConverter.to_rgb怎麽用?Python colorConverter.to_rgb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.colors.colorConverter的用法示例。


在下文中一共展示了colorConverter.to_rgb方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_combobox_lineprops_changed

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [as 別名]
def on_combobox_lineprops_changed(self, item):
        'update the widgets from the active line'
        if not self._inited: return
        self._updateson = False
        line = self.get_active_line()

        ls = line.get_linestyle()
        if ls is None: ls = 'None'
        self.cbox_linestyles.set_active(self.linestyled[ls])

        marker = line.get_marker()
        if marker is None: marker = 'None'
        self.cbox_markers.set_active(self.markerd[marker])

        r,g,b = colorConverter.to_rgb(line.get_color())
        color = gtk.gdk.Color(*[int(val*65535) for val in (r,g,b)])
        button = self.wtree.get_widget('colorbutton_linestyle')
        button.set_color(color)

        r,g,b = colorConverter.to_rgb(line.get_markerfacecolor())
        color = gtk.gdk.Color(*[int(val*65535) for val in (r,g,b)])
        button = self.wtree.get_widget('colorbutton_markerface')
        button.set_color(color)
        self._updateson = True 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:26,代碼來源:backend_gtk.py

示例2: on_combobox_lineprops_changed

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [as 別名]
def on_combobox_lineprops_changed(self, item):
        'update the widgets from the active line'
        if not self._inited: return
        self._updateson = False
        line = self.get_active_line()

        ls = line.get_linestyle()
        if ls is None: ls = 'None'
        self.cbox_linestyles.set_active(self.linestyled[ls])

        marker = line.get_marker()
        if marker is None: marker = 'None'
        self.cbox_markers.set_active(self.markerd[marker])

        r,g,b = colorConverter.to_rgb(line.get_color())
        color = Gdk.Color(*[int(val*65535) for val in r,g,b])
        button = self.wtree.get_widget('colorbutton_linestyle')
        button.set_color(color)

        r,g,b = colorConverter.to_rgb(line.get_markerfacecolor())
        color = Gdk.Color(*[int(val*65535) for val in r,g,b])
        button = self.wtree.get_widget('colorbutton_markerface')
        button.set_color(color)
        self._updateson = True 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:26,代碼來源:backend_gtk3.py

示例3: on_combobox_lineprops_changed

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [as 別名]
def on_combobox_lineprops_changed(self, item):
        'update the widgets from the active line'
        if not self._inited: return
        self._updateson = False
        line = self.get_active_line()

        ls = line.get_linestyle()
        if ls is None: ls = 'None'
        self.cbox_linestyles.set_active(self.linestyled[ls])

        marker = line.get_marker()
        if marker is None: marker = 'None'
        self.cbox_markers.set_active(self.markerd[marker])

        r,g,b = colorConverter.to_rgb(line.get_color())
        color = Gdk.Color(*[int(val*65535) for val in (r,g,b)])
        button = self.wtree.get_widget('colorbutton_linestyle')
        button.set_color(color)

        r,g,b = colorConverter.to_rgb(line.get_markerfacecolor())
        color = Gdk.Color(*[int(val*65535) for val in (r,g,b)])
        button = self.wtree.get_widget('colorbutton_markerface')
        button.set_color(color)
        self._updateson = True 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:26,代碼來源:backend_gtk3.py

示例4: gradient

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [as 別名]
def gradient(cmin, cmax):
    if isinstance(cmin, str):
        cmin = colorConverter.to_rgb(cmin)
    if isinstance(cmax, str):
        cmax = colorConverter.to_rgb(cmax)

    cdict = {
        'red':   [(0, 0,       cmin[0]),
                  (1, cmax[0], 1)],
        'green': [(0, 0,       cmin[1]),
                  (1, cmax[1], 1)],
        'blue':  [(0, 0,       cmin[2]),
                  (1, cmax[2], 1)]
        }

    return mpl.colors.LinearSegmentedColormap('cmap', cdict, N=1000)

#=========================================================================================
# Colors
#========================================================================================= 
開發者ID:frsong,項目名稱:pycog,代碼行數:22,代碼來源:figtools.py

示例5: export_color

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [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

示例6: col2hex

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [as 別名]
def col2hex(color):
    """Convert matplotlib color to hex before passing to Qt"""
    return rgb2hex(colorConverter.to_rgb(color)) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:5,代碼來源:formlayout.py

示例7: apply_alpha

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [as 別名]
def apply_alpha(color, alpha=0.7):
    fg = np.asarray(colorConverter.to_rgb(color))
    bg = np.ones(3)

    return tuple(alpha*fg + (1-alpha)*bg) 
開發者ID:frsong,項目名稱:pycog,代碼行數:7,代碼來源:figtools.py

示例8: color_to_hex

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [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

示例9: _register_cmap_transparent

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [as 別名]
def _register_cmap_transparent(name, color):
    """Create a color map from a given color to transparent."""
    from matplotlib.colors import colorConverter, LinearSegmentedColormap
    red, green, blue = colorConverter.to_rgb(color)
    cdict = {'red': ((0, red, red), (1, red, red)),
             'green': ((0, green, green), (1, green, green)),
             'blue': ((0, blue, blue), (1, blue, blue)),
             'alpha': ((0, 0, 0), (1, 1, 1))}
    cmap = LinearSegmentedColormap(name, cdict)
    _plt.cm.register_cmap(cmap=cmap) 
開發者ID:sfstoolbox,項目名稱:sfs-python,代碼行數:12,代碼來源:plot2d.py

示例10: volume_overlay

# 需要導入模塊: from matplotlib.colors import colorConverter [as 別名]
# 或者: from matplotlib.colors.colorConverter import to_rgb [as 別名]
def volume_overlay(ax, opens, closes, volumes,
                   colorup='k', colordown='r',
                   width=4, alpha=1.0):
    """
    Add a volume overlay to the current axes.  The opens and closes
    are used to determine the color of the bar.  -1 is missing.  If a
    value is missing on one it must be missing on all

    ax          : an Axes instance to plot to
    width       : the bar width in points
    colorup     : the color of the lines where close >= open
    colordown   : the color of the lines where close <  open
    alpha       : bar transparency


    """

    r,g,b = colorConverter.to_rgb(colorup)
    colorup = r,g,b,alpha
    r,g,b = colorConverter.to_rgb(colordown)
    colordown = r,g,b,alpha
    colord = { True : colorup,
               False : colordown,
               }
    colors = [colord[open<close] for open, close in zip(opens, closes) if open!=-1 and close !=-1]

    delta = width/2.
    bars = [ ( (i-delta, 0), (i-delta, v), (i+delta, v), (i+delta, 0)) for i, v in enumerate(volumes) if v != -1 ]

    barCollection = PolyCollection(bars,
                                   facecolors   = colors,
                                   edgecolors   = ( (0,0,0,1), ),
                                   antialiaseds = (0,),
                                   linewidths   = (0.5,),
                                   )

    ax.add_collection(barCollection)
    corners = (0, 0), (len(bars), max(volumes))
    ax.update_datalim(corners)
    ax.autoscale_view()

    # add these last
    return barCollection 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:45,代碼來源:finance.py


注:本文中的matplotlib.colors.colorConverter.to_rgb方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。