Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Create a Vector of Colors from a Vector of Gray Levels in R Programming – gray() or grey() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

gray() or grey() function in R Language is used to create a vector of colors from a vector of gray levels.

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”.

Example 1:




# R program to illustrate
# gray function
  
# Calling the gray() function
gray(0)
gray(1)

Output:

[1] "#000000"
[1] "#FFFFFF"

Example 2:




# R program to illustrate
# gray function
  
# Calling the gray() function
gray(0:9 / 9)

Output:

[1] "#000000" "#1C1C1C" "#393939" "#555555" "#717171" "#8E8E8E" "#AAAAAA"
[8] "#C6C6C6" "#E3E3E3" "#FFFFFF"
My Personal Notes arrow_drop_up
Last Updated : 30 Jun, 2020
Like Article
Save Article
Similar Reads