我正在尝试绘制此光栅文件的图像。图例的颜色是这样的:低值用红色,高值用绿色。
但通常红色与高值相关联。这就是为什么我用来rev
反转图例的颜色。但是我得到了一些不同的东西。是否有另一个功能可以反转图例的颜色并保持颜色不变。
require(raster)
require(fields)
r = raster(y)
extent(r) = extent(c(xmn=-180,xmx=180,ymn=-90,ymx=90))
plot(r, col = rainbow(20, s = 1, v = 1, start = 0,
end = 1),lab.breaks=seq(0,0.6,0.05),
breaks=seq(0,0.6,0.05), zlim=c(0.0,0.6),horizontal = TRUE,
xlab="Longitude", ylab="Latitude",legend.shrink = 0.9,
legend.width = 1.2)
然后我用这个给了我:
plot(r, col = rev(rainbow(20, s = 1, v = 1, start = 0, end = 1)),
lab.breaks=seq(0,0.6,0.05),breaks=seq(0,0.6,0.05),
zlim=c(0.0,0.6),horizontal = TRUE, xlab="Longitude",
ylab="Latitude",legend.shrink = 0.9,legend.width = 1.2)