Search code examples
rraster

Increasing size of font on legend


I am making a plot like so:

library(raster)

r <- raster(volcano)
r2 <- raster(volcano)
r3 <- raster(volcano)
r4 <- raster(volcano)

opar = par(mfrow=c(2, 2), mar = c(0,0,2,0), oma = c(0,0,0,0))
asp = 0.8

print (plot(r, axes=F, legend=F, box=F, useRaster=F,asp = asp))
title(main = 'Time Series', line = 0.6, adj = 0.45)

print (plot(r2, axes=F, legend=F, box=F, useRaster=F,asp = asp))
title(main = 'Early Season', line = 0.6, adj = 0.45)

print (plot(r3, axes=F,legend=F, box=F, useRaster=F,asp = asp))
title(main = 'Peak Summer', line = 0.6, adj = 0.45)

print (plot(r4,legend=F, box=F, useRaster=F,asp = asp))
title(main = 'Late Season', line = 0.6, adj = 0.45)
print (plot(r, legend.only=TRUE, legend.width = 1, legend.shrink=0.75, smallplot = c(0.85,0.90, 0.04, 0.63), legend.args= list(text='Slope', side=2, font=3, line = 0.2, cex=2)))

and I want to increase the size of the font in the legend. In the above, cex = 2 increases or decreases the size of "Slope" but I want to increase the size of the numbers which represent the values in the plots themselves.

My output is:

enter image description here


Solution

  • cex.axis should work. This is a reproducible example:

      library(raster)
      r <- raster(nrows=10, ncols=10)
      r <- setValues(r, 1:ncell(r))
    
     opar = par(mfrow=c(2, 1), mar = c(0,0,2.5, 0))
      plot(r, legend.width = 1, legend.shrink=0.75, axis.args=list( cex.axis=2), legend.args=list(text='Slope', side=2))
      plot(r, legend.width = 1, legend.shrink=0.75, axis.args=list( cex.axis=0.5), legend.args=list(text='Slope', side=2))
    

    enter image description here