本文整理汇总了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
示例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
示例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
示例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
#=========================================================================================
示例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])+")"
示例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))
示例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)
示例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))
示例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)
示例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