RGB到html中的colormap Matplotlib子集
我对使用Matplotlib中的RGB到html中的colormap Matplotlib子集,matplotlib,colormap,Matplotlib,Colormap,我对使用Matplotlib中的cmap('hot')作为Bokeh调色板感兴趣 首先,我选择Matplotlib colormap子集,该子集由 from Matplotlib.pyplot as plt colors_mpl = [i for i in plt.get_cmap('hot')(np.linspace(0.05, 0.95, 6))] 最初,给定一组RGB颜色,我可以通过使用内置函数转换为html from matplotlib.colors import to_hex co
cmap('hot')
作为Bokeh调色板感兴趣
首先,我选择Matplotlib colormap子集,该子集由
from Matplotlib.pyplot as plt
colors_mpl = [i for i in plt.get_cmap('hot')(np.linspace(0.05, 0.95, 6))]
最初,给定一组RGB颜色,我可以通过使用内置函数转换为html
from matplotlib.colors import to_hex
colors_html = [to_hex(rgb/255) for rgb in colors_mpl]]
但是,我得到的输出不是预期的,因为我得到的颜色差异非常小:
['#000000', '#010000', '#010000', '#010100', '#010100', '#010101']
预期产量为
['#2a0000', '#a30000', '#ff1d00', '#ff9800', '#ffff1b', '#ffffd0']
关于如何正确地将颜色映射转换为html,有什么想法吗?不要除以255
,颜色\u mplt
已经按比例0-1
:
colors_html = [to_hex(rgb) for rgb in colors_mpl]
# out
# ['#2a0000', '#a30000', '#ff1d00', '#ff9800', '#ffff1b', '#ffffd0']