Open In App

Create a Vector of Colors with specified Hue, Saturation and Value in R Programming – hsv() Function

Last Updated : 30 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

hsv() function in R Language is used to create a vector of colors from vectors specifying hue, saturation and value.

Syntax: hsv(h, s, v)

Parameters:
h, s, v: numeric vectors of values in the range [0, 1] for ‘hue’, ‘saturation’ and ‘value’ to be combined to form a vector of colors.

Example 1:




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


Output:

[1] "#000000"
[1] "#FF0000"

Example 2:




# R program to illustrate
# hsv function
  
# Calling the hsv() function
hsv(0.1, 0.3, 0.5)
hsv(1, 0.08, 0.245)


Output:

[1] "#807059"
[1] "#3E3939"

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads