在 R 编程中从灰度向量创建颜色向量 – gray() 或 gray()函数
R 语言中的gray() or grey()
函数用于从灰度向量创建颜色向量。
Syntax:
gray(level)
or
grey(level)
Parameters:
level: a vector of desired gray levels between 0 and 1; zero indicates “black” and one indicates “white”.
示例 1:
# R program to illustrate
# gray function
# Calling the gray() function
gray(0)
gray(1)
输出:
[1] "#000000"
[1] "#FFFFFF"
示例 2:
# R program to illustrate
# gray function
# Calling the gray() function
gray(0:9 / 9)
输出:
[1] "#000000" "#1C1C1C" "#393939" "#555555" "#717171" "#8E8E8E" "#AAAAAA"
[8] "#C6C6C6" "#E3E3E3" "#FFFFFF"