 Open in App
Not now

# Get the Hexadecimal Code of the Specified Shade in R Programming – rgb() Function

• Last Updated : 02 Mar, 2021

rgb() function in R Language is used to specify the shade of the color red, green, and blue between 0 and 1. Further the specified shades of these three basic components will be mixed to form a new shade. The shade of the color red, green, and blue can also be specified between 0 and 255. But there will be an added argument max=255 while using this range. This function returns the corresponding hexadecimal code of the specified shade.

Syntax: rgb(a, b, c, max = 255)
Parameters:

Example 1:

## Python3

 `# R program to illustrate` `# rgb function`   `# Calling the rgb() function with` `# shade of color between 0 to 1` `rgb(``0``, ``1``, ``0.5``) ` `rgb(``0.9``, ``0.7``, ``0.8``) ` `rgb(``0``, ``0.7``, ``1``) ` `rgb(``0``, ``0``, ``0``) ` `rgb(``1``, ``1``, ``1``) `

Output:

``` "#00FF80"
 "#E6B3CC"
 "#00B3FF"
 "#000000"
 "#FFFFFF"```

Example 2:

## Python3

 `# R program to illustrate` `# rgb function`   `# Calling the rgb() function with` `# shade of color between 0 and 255` `# with added argument max = 255` `rgb(``0``, ``0``, ``0``, ``max` `=` `255``) ` `rgb(``5``, ``7``, ``60``, ``max` `=` `255``) ` `rgb(``255``, ``255``, ``255``, ``max` `=` `255``) `

Output:

``` "#000000"
 "#05073C"
 "#FFFFFF"```

My Personal Notes arrow_drop_up
Related Articles