How to set colors in the barplot function in R language?
In R language, you can use the col parameter to set the color of a barplot. Here is the specific method:
- abridge
barplot(heights, col = "red")
- make more space
barplot(heights, col = c("red", "green", "blue"))
- rainbow() – a function that generates a sequence of colors in the order of the colors of a rainbow.
- generate a color palette based on heat levels
- generate a list of colors
- collected
- create a rainbow
barplot(heights, col = rainbow(7))
- Create a color palette with smoothly changing colors
- short for column
myColors <- colorRampPalette(c("red", "white", "blue"))
barplot(heights, col = myColors(length(heights)))
Please choose the appropriate method to set the color of the bar plot according to your needs.