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

Related Articles

Create a Range of Colors between the Specified Colors in R Programming – colorRampPalette() Function

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

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:




# R program to create a color range
  
# Apply colorRampPalette Function
fun_color_range <- colorRampPalette(c("Green", "darkgreen"))   
my_colors <- fun_color_range(100)  
  
# Plotting a graph
plot(1:100, pch = 20, col = my_colors)

Output:

Example 2:




# R program to create a color range
  
# Apply colorRampPalette Function
fun_color_range <- colorRampPalette(c("blue", "orange"))   
my_colors <- fun_color_range(100)  
  
# Plotting a graph
plot(1:100, pch = 40, col = my_colors)

Output :

My Personal Notes arrow_drop_up
Last Updated : 30 Jun, 2020
Like Article
Save Article
Similar Reads