栅格图中等距的图例

时间:2019-04-30 18:10:36

标签: r plot raster viridis

library(raster)
library(viridis)

data(volcano)
volcanoR <- raster(volcano)

breakpoints <- c(94,100,120,140,160,180,185, 189, 195)

par(mfrow = c(1, 2))

plot(volcanoR, main = "1")
plot(volcanoR, breaks = breakpoints, col = viridis(length(breakpoints) -1), main = "2")

enter image description here

在图2中,您会看到图例标签彼此非常接近,甚至重叠。有什么办法,我可以让它们不重叠且等距,如图1所示。

1 个答案:

答案 0 :(得分:0)

这个问题我不清楚,但我认为您可以使用levelplot来做到这一点:

library(raster)
library(lattice)

data(volcano)
volcanoR <- raster(volcano)

breakpoints <- c(94,100,120,140,160,180,185, 189, 195)
levelplot(volcano, at=breakpoints, labels=breakpoints,
          par.settings=list(regions=list(col=topo.colors(8))))

enter image description here