I use plot function to plot a raster in R. The plot function adds a legend as default. However, the default legend added does not have a title. For instance I need to add the unit such as meters.
I cannot add a title to legend. How can I do it in plot function?
plot(raster, main = "text", sub = "This is elevation", lwd =5, col =my.palette, legend = T )
Best Answer
You can add a title to the legend using
legend.args
in the call to plot the raster. E.g:The above snippet is taken from this question where you can also find a few more expansive examples of how the legend can be formatted (for the raster package): https://stackoverflow.com/questions/9436947/legend-properties-when-legend-only-t-raster-package