Open In App
Related Articles

Create a Range of Contiguous Colors Clustered around the Red Spectrum of the RGB Scale in R Programming – heat.colors() Function

Improve Article
Save Article
Like Article

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)

n: desired length of the returned color vector

Example 1:

# R program to illustrate
# heat.colors function
# Calling heat.colors() function


[1] "#FF0000FF" "#FFFF00FF"
[1] "#FF0000FF" "#FF8000FF" "#FFFF00FF" "#FFFF80FF"
[1] "#FF0000FF" "#FF4000FF" "#FF8000FF" "#FFBF00FF" "#FFFF00FF" "#FFFF80FF"

Example 2:

# R program to illustrate
# heat.colors function
# Using heat.colors() function to
# plot 6 different color
barplot(1:6, col = heat.colors(6))


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 30 Jun, 2020
Like Article
Save Article
Similar Reads