栅格图中的等间距图例

问题描述 投票:1回答:1
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所示。

r plot raster viridis
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.