Create a Range of Colors between the Specified Colors in R Programming – colorRampPalette() Function
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 :
Please Login to comment...