R 晶格线框颜色

  • 本文关键字:颜色 线框 r lattice
  • 更新时间 :
  • 英文 :


我正在尝试创建法罗周围地区(仅海底(的测深图。 我正在使用格子和线框功能。所以我做到了:

depthfaroe <-  getNOAA.bathy(lon1 = -11, lon2= -2, lat1 = 60, lat2 = 63, resolution = 1) %>% 
fortify()
depthfaroeNeg <- depthfaroe
depthfaroeNeg$z[which(depthfaroeNeg$z > 0)] <- 0 #I remove the detail on the land
depthfaroe <- as.bathy(depthfaroeNeg)
wireframe(unclass(depthfaroe), shade = T, aspect = c(0.6, 0.1),
screen = list(z = 0, x = -20),
par.settings = list(axis.line=list(col="transparent")),
zoom = 1.5,
par.box=list(col=NA),
col.regions = colorRampPalette(c("blue", "pink"))(100)
)

但是,不可能使col.region设置工作。此外,我想用灰色将深度为 0 的区域着色。 所以基本上,有两个问题:

  1. 为什么 col.region 参数不起作用(手动定义线框的颜色似乎不起作用(
  2. 如何使颜色渐变和一个特定 z 具有特殊颜色(例如,对于 z = 0(?

提前非常感谢您的建议

夏 洛特

感谢软件包开发器,我找到了答案:

ramp.fun <- colorRamp(c("darkblue", "cadetblue1", "burlywood4"))
custom.palette <- function(irr, ref, height, rampfun = ramp.fun)
{if(height != 1) {
## convert height to color using rampfun and map to HSV space
h.hsv <- rgb2hsv(t(rampfun(height)))
## reduce 'V' (brightness): multiply by irradiance
toReturn <- hsv(h = h.hsv["h",],
s = h.hsv["s",],
v = irr * h.hsv["v",])
} else {
toReturn <- "grey"
}
return(toReturn)
}
xlim <- c(-35, 10)
ylim <- c(55, 70)
m <- map_data("worldHires", xlim = xlim, ylim = ylim)
depth <-  getNOAA.bathy(lon1 = xlim[1], lon2= xlim[2], lat1 = ylim[2], lat2 = ylim[1], resolution = 2) %>% 
fortify()
depthNeg <- depth
depthNeg$z[which(depthNeg$z > 0)] <- 0
depth <- as.bathy(depthNeg)
wireframe(unclass(depth), shade = T,
aspect = c(0.6, 0.1),
screen = list(z = 0, x = -20),
par.settings = list(axis.line=list(col="transparent")),
zoom = 1.5,
par.box=list(col=NA),
col='transparent',
shade.colors.palette = custom.palette
)

我希望它能帮助:)

干杯!

最新更新