【问题标题】:Generating different shades of the same colour in R在R中生成相同颜色的不同阴影
【发布时间】:2018-11-30 22:00:38
【问题描述】:

我想生成从浅色调到深色调的不同色调的颜色

colfunc <- colorRampPalette(c("green", "red"))
colfunc(10)

plot(rep(1,10),col=colfunc(10),pch=19,cex=3)

如果我尝试以单一颜色运行它

 colfunc <- colorRampPalette("green")
 colfunc(10)
 [1] "#00FF00" "#00FF00" "#00FF00" "#00FF00" "#00FF00" "#00FF00"
 [7] "#00FF00" "#00FF00" "#00FF00" "#00FF00"

它返回相同的值。如何生成从浅绿色到深绿色的单一颜色的不同色调?

【问题讨论】:

  • 选择多个绿色? grDevice::colors 中的各种颜色。见this cheat sheet。包RColorBrewerGreens 调色板。
  • 你也可以玩rgb:改编自示例:rgb(green = (0:10)/10, red = 0, blue = 0)
  • 另一个chart of R colors 在这种情况下可能有用

标签: r plot colors color-palette


【解决方案1】:
fc <- colorRampPalette(c("green", "darkgreen"))
plot(rep(1, 10),col = fc(10), pch = 19, cex = 3)

这是你需要的吗?

【讨论】:

    猜你喜欢
    • 2017-03-29
    • 1970-01-01
    • 2021-05-03
    • 1970-01-01
    • 2015-12-11
    • 2020-07-11
    • 1970-01-01
    • 2021-04-27
    • 1970-01-01
    相关资源
    最近更新 更多