Create a Range of Colors between the Specified Colors in R Programming – colorRampPalette() Function
Last Updated :
30 Jun, 2020
colorRampPalette()
function in R Language is used to create a color range between two colors specified as arguments to the function. This function is used to specify the starting and ending color of the range.
Syntax:
colorRampPalette(c(“color1”, “color2”))
Parameters:
color1, color2: starting and ending colors of the range.
Returns: color range between specified colors
Example:
fun_color_range <- colorRampPalette ( c ( "Green" , "darkgreen" ))
my_colors <- fun_color_range (100)
plot (1:100, pch = 20, col = my_colors)
|
Output:
Example 2:
fun_color_range <- colorRampPalette ( c ( "blue" , "orange" ))
my_colors <- fun_color_range (100)
plot (1:100, pch = 40, col = my_colors)
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...