I want to generate different shades of a colour going from lighter tone to darker tone
colfunc <- colorRampPalette(c("green", "red"))
colfunc(10)
plot(rep(1,10),col=colfunc(10),pch=19,cex=3)
If I try to run this for a single colour
colfunc <- colorRampPalette("green")
colfunc(10)
[1] "#00FF00" "#00FF00" "#00FF00" "#00FF00" "#00FF00" "#00FF00"
[7] "#00FF00" "#00FF00" "#00FF00" "#00FF00"
It returns me the same values. How can I generate different shades of a single colour say going from light green to darker green?
Tints and shades are art terminology for the lighter and darker variations of a single color. They're created by adding white (for tints) or black (for shades) to a base color.
In R, colors can be specified either by name (e.g col = “red”) or as a hexadecimal RGB triplet (such as col = “#FFCC00”). You can also use other color systems such as ones taken from the RColorBrewer package.
To see a list of the named colors (just the names, not the colors themselves) use the command colors(). R uses hexadecimal colors. These are represented as strings of six characters. Red, green, and blue components are specified as two hexadecimal digits (0–9, A–F), in the form #rrggbb.
fc <- colorRampPalette(c("green", "darkgreen"))
plot(rep(1, 10),col = fc(10), pch = 19, cex = 3)
Is it what you need?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With