颜色名称
颜色名称
Python中的数据科学:可以在matplotlib
中指定的颜色的名称和列表
cmap名称
beiz注意:matplotlib cmap(颜色图)参数的列表。
通过RGB值+透明度的颜色规格A
- 按字符串指定:"#?????????",RGBA顺序从顶部开始两位。为了透明起见,最后两位为00。
- 由元组指定:(R,G,B,A),每个值为0-1。透明度为0.0
顺便说一句,完全透明和不可见的状态称为"透明度0%"。
列表如下。
原色词典
Qiita @ konifar:ARGB颜色代码透明度摘要
参考:Python通过示例:透明颜色
示例:
1 2 3 4 5 6 7 8 9 | import numpy as np import matplotlib.pyplot as plt x = np.arange(0.0, 15.0, 0.1) y = np.sin(x) plt.plot(y , color='#ff4500' ) # orangered plt.plot(y - 1.0, color='#4169e1' ) # royalblue plt.plot(y - 2.0, color='#4169e199') # royalblue,透明度60% plt.plot(y - 3.0, color='#4169e133') # royalblue,透明度20% plt.plot(y - 4.0, color='#4169e100') # royalblue,透明度0%なので見えない |
用于将颜色名称转换为RGB值的Colors.to_rgb(color_name)
- to_rgb:(R,G,B)长度3个元组
- to_rgba:(R,G,B,A)长度4元组
这样可以轻松指定颜色名称+透明度值。
1 2 3 | from matplotlib import colors print(colors.to_rgb ('royalblue')) # (0.2549019607843137, 0.4117647058823529, 0.8823529411764706) print(colors.to_rgba('royalblue')) # (0.2549019607843137, 0.4117647058823529, 0.8823529411764706, 1.0) |
stackoverflow:Python从颜色名称转换为RGB
分别指定imshow颜色
1 2 3 4 5 6 7 | from matplotlib import colors cmap = colors.ListedColormap(['white', 'red']) bounds=[0,5,10] norm = colors.BoundaryNorm(bounds, cmap.N) img = plt.imshow(zvals, interpolation='nearest', cmap=cmap, norm=norm) plt.colorbar(img, cmap=cmap, norm=norm, boundaries=bounds, ticks=[0, 5, 10]) |
https://stackoverflow.com/questions/9707676/defining-a-discrete-colormap-for-imshow-in-matplotlib
从一个颜色图中离散指定颜色
绘制多个折线图等时
1 2 3 | cmap = plt.get_cmap("Blues") for i in xrange(len(y)): plt.plot(x, y[i], c=cmap(float(i)/N)) |
Qiita @ Tatejimaru137:将Matplotlib图形颜色与相似颜色对齐(颜色图)
调整后的颜色图标准
Qiita @ aisha:[Python]调整了颜色贴图标准