更新时间:2023-01-27 09:54:06
您可以使用 color.id code> plotrix 包*:
You may use the convenience function color.id
from the plotrix
package*:
给出指定为十六进制字符串的颜色,找到最接近的颜色
Given a color specified as a hex string, find the closest match in the table of known (named) colors.
library(plotrix)
sapply(rainbow(4), color.id)
# $`#FF0000FF`
# [1] "red" "red1"
#
# $`#80FF00FF`
# [1] "chartreuse" "chartreuse1"
#
# $`#00FFFFFF`
# [1] "cyan" "cyan1"
#
# $`#8000FFFF`
# [1] "purple"
*在此归功于Jim Lemon及其答案:将颜色十六进制代码转换为颜色名称。