R点阵线框颜色 [英] R lattice wireframe color

查看:52
本文介绍了R点阵线框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制法罗(仅海底)周围地区的测深图.我正在使用晶格和线框功能.所以我做到了:

I am trying to create a map of the bathymetry of the region around Faroe (only the sea bottom). I am using lattice and wireframe function. So I did:

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的区域涂成灰色.所以基本上,有两个问题:

However, impossible to make the col.region setting work. Moreover, I would like to color in grey the region with a depth of 0. So basically, two question:

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

非常感谢您的建议

夏洛特

推荐答案

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

Thanks to the package developper, I found an answer:

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
)

我希望它会有所帮助:)

I hope it will help :)

干杯!

Cha

这篇关于R点阵线框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆