Create a Range of Contiguous Colors Clustered around the Red Spectrum of the RGB Scale in R Programming – heat.colors() Function
Last Updated :
30 Jun, 2020
heat.colors()
function in R Language is used to create a ramp of contiguous colors clustered around the color orange in the red spectrum of the RGB scale. This function also returns the hexadecimal code of the colours available. This hexadecimal code is of eight digits. This is because the last two digits specify the level of transparency (where FF is opaque and 00 is transparent).
Syntax: heat.colors(n)
Parameters:
n: desired length of the returned color vector
Example 1:
heat.colors( 2 )
heat.colors( 4 )
heat.colors( 6 )
|
Output:
[1] "#FF0000FF" "#FFFF00FF"
[1] "#FF0000FF" "#FF8000FF" "#FFFF00FF" "#FFFF80FF"
[1] "#FF0000FF" "#FF4000FF" "#FF8000FF" "#FFBF00FF" "#FFFF00FF" "#FFFF80FF"
Example 2:
barplot( 1 : 6 , col = heat.colors( 6 ))
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...