[英]Equally spaced legend in a raster plot
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")
In the plot 2, you see that the legend labels are very close to each other and even overlapping. 在图2中,您会看到图例标签彼此非常接近,甚至重叠。 Is there any way, I can have them not overlapping and equal spaced like in Fig 1.
有什么办法,我可以让它们不重叠且等距,如图1所示。
This question is not clear to me but I think you can do this using levelplot
: 这个问题对我来说并不明确,但我认为您可以使用
levelplot
来做到这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))))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.