R中光栅包的默认调色板是什么

  • 本文关键字:默认 调色板 是什么 r
  • 更新时间 :
  • 英文 :


如何在R中重新创建光栅包的默认调色板?在联机文档中找不到有关默认光栅打印配色方案的详细信息。谢谢

如果我们查看Raster类型对象的自定义绘图方法的源代码,我们将看到第12行显示:

col <- rev(terrain.colors(255))

如果您键入terrain.colors,您将看到用于计算颜色的代码:

terrain.colors
function (n, alpha = 1, rev = FALSE) 
{
if ((n <- as.integer(n[1L])) > 0) {
k <- n%/%2
h <- c(4/12, 2/12, 0/12)
s <- c(1, 1, 0)
v <- c(0.65, 0.9, 0.95)
cols <- c(hsv(h = seq.int(h[1L], h[2L], length.out = k), 
s = seq.int(s[1L], s[2L], length.out = k), v = seq.int(v[1L], 
v[2L], length.out = k), alpha = alpha), hsv(h = seq.int(h[2L], 
h[3L], length.out = n - k + 1)[-1L], s = seq.int(s[2L], 
s[3L], length.out = n - k + 1)[-1L], v = seq.int(v[2L], 
v[3L], length.out = n - k + 1)[-1L], alpha = alpha))
if (rev) 
cols <- rev(cols)
cols
}
else character()
}

最新更新