When plotting only the legend (of a raster object – a colorbar):
require(raster)
r = raster()
r[] = 1
plot(r, legend=F)
plot(r, zlim=c(-10,10), legend.only=T)
how can I control the legend axis label size, tick length, and other legend properties? I know I can call par(...) before the last plot() call, but is there a cleaner way?
You can pass
axis.argsandlegend.argsas arguments to the legend only function call, as forimage.plotin thefieldspackage.For example, to specify tick positions and labels, and to reduce tick label size, the following should do the trick. It will also accept arguments such as
legend.widthandlegend.shrink.