I wish to make contour plots of netcdf files. I first extract the nc files and make them into raster format (easier to plot). The plots come fine, but I want to scale up the size of the color key bar present on the right side.
Here is my R script:
lapply(c("ncdf4","raster","sf","Metrics"),require,character.only=TRUE)
setwd("~/Desktop/Feb_24")
border <- read_sf("India_boundary/India_Boundary.shp")
ncfile <- nc_open("monthwise/ACCESS-CM2_historic_monmean.nc")
wsp_mod <- ncvar_get(ncfile,varid="sfcWind")
pal <- colorRampPalette(c("darkblue","blue","cyan","green","yellow","orange","red"))
for(i in seq(1:12)){
r_mon <- raster(wsp_mod[,,i])
r_mon <- t(flip(r_mon,1))
r_mon@extent <- extent(65.125,100.125,3.125,40.125)
r_mon <-mask(crop(r_mon,extent(border)),border)
r_mon@title <-"Multi year monthly mean"
png(filename=paste(i,"_ACCESS-CM2_historic.png"),width=1400,height=1400)
par(mar=c(5,6,4,1)+.1)
plot(r_mon,xlab="Longitude",ylab="Latitude",main=paste(i),cex.lab=1.3,cex.axis=1.2,cex.main=1.3,col=pal(8),breaks=c(0,1,2,3,4,5,6,7,8))
lines(border,col="black")
dev.off()
}
the arguments, cex.lab, cex.axis, cex.main, do not scale up the color key bar. I have searched throughout the documentation to find a parameter that controls this size but in vain. Do let me know if theres a way to specifically control the size of the color bar.
If you are using
raster::plot()then uselegend.widthparameter, like:Created on 2024-03-05 with reprex v2.1.0