f <- system.file("ex/elev.tif", package="terra")
r <- rast(f)
plot(r, axes=FALSE, legend=FALSE)
add_box()
for (i in 1:4) add_mtext("margin text", i, cex=i, col=i, line=2-i)
# align the text along the margin
plot(r, axes=FALSE, legend=FALSE)
add_box()
for (i in 1:4) {
add_mtext("start", i, adj=0, col="blue")
add_mtext("middle", i, adj=0.5, cex=1.5)
add_mtext("end", i, adj=1, col="red")
}
Run the code above in your browser using DataLab