R语言 打印栅格时更改图例标题的大小和方向

jpfvwuh4  于 2023-06-03  发布在  其他
关注(0)|答案(1)|浏览(248)
library(terra)
library(RColorBrewer)

# sample polygon
p <- system.file("ex/lux.shp", package="terra")
p <- terra::vect(p)

# sample raster
r <- system.file("ex/elev.tif", package="terra")
r <- terra::rast(r)
r <- terra::crop(r, p , snap = "out", mask = T)

terra::plot(r,
           col = brewer.pal(9, "pastel1"),
           cex.main = 2,
           smooth = T,
           legend = T,
           plg = list(title = "Score"),
           axes = TRUE,
           mar=c(3,3,3,6))
plot(p, add = T)

如何更改图例标题“得分”的大小和方向。我想定向标题,使其垂直并沿着图例,并更改图例标题的大小?

1zmg4dgp

1zmg4dgp1#

你可以在任何你想要的地方添加文本。比如说,

library(terra)
p <- terra::vect(system.file("ex/lux.shp", package="terra"))
r <- terra::rast(system.file("ex/elev.tif", package="terra"))

plot(r, mar=c(3,3,3,6))
text(x=6.77, y=49.95, "Score", srt=-90, cex=2, xpd=NA, pos=4)
lines(p)

相关问题