I have defined a colorRampPalette:
my.colors = colorRampPalette(c("light green", "yellow", "orange", "red"))
How can I plot a colorbar "legend" item for it, preferably using only the base packages? I am after a rectangle filled with that color gradient.
What I am really after is a way to produce the same type of legend (color bar) that is plotted with a "raster" raster:
require(raster)
plot(raster("myfile.tif"), legend=T)
I need to be able to place this on top of another plot.
See Question&Answers more detail:os