[英]Is there a pre-defined color list? so I could access the colors by index
I was wondering if there is a pre-defined color list.我想知道是否有预定义的颜色列表。
For example colors = ['red', 'orange', 'yellow'...]
例如
colors = ['red', 'orange', 'yellow'...]
I wanted assign items with colors, However the number of items is not set and is unknown.我想用 colors 分配项目,但是项目数量未设置且未知。
So I was trying to set a code such as所以我试图设置一个代码,例如
color_dict = {}
for num, i in enumerate(list_with_random_items):
color_dict[i] = colors[num]
Is creating my own list of colors (ex. colors=['red', 'yellow']
) the only way?创建我自己的 colors 列表(例如
colors=['red', 'yellow']
)是唯一的方法吗?
I used matplotlib.colors
我用过
matplotlib.colors
import matplotlib.colors as mcl
mcl.BASE_COLORS
mlc.TABLEAU_COLORS
gives output of给出 output 的
{'b': (0, 0, 1),
'g': (0, 0.5, 0),
'r': (1, 0, 0),
'c': (0, 0.75, 0.75),
'm': (0.75, 0, 0.75),
'y': (0.75, 0.75, 0),
'k': (0, 0, 0),
'w': (1, 1, 1)}
==========================
OrderedDict([('tab:blue', '#1f77b4'),
('tab:orange', '#ff7f0e'),
('tab:green', '#2ca02c'),
('tab:red', '#d62728'),
('tab:purple', '#9467bd'),
('tab:brown', '#8c564b'),
('tab:pink', '#e377c2'),
('tab:gray', '#7f7f7f'),
('tab:olive', '#bcbd22'),
('tab:cyan', '#17becf')])
and just used the keys of it并且只是使用了它的键
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.