【问题标题】:plot in red, green or blue levels绘制红色、绿色或蓝色级别
【发布时间】:2013-12-19 22:49:04
【问题描述】:

有没有办法使用函数plot() 绘制矩阵/图像,带有红色或绿色或蓝色级别,就像颜色选项grey(level, alpha = NULL) 一样?

灰度等级介于 0(黑色)和 1(白色)之间。

我正在寻找与 RGB 相同的东西:

  • 红色级别介于 0(红色)和 1(白色)之间。
  • 绿色级别将介于 0(绿色)和 1(白色)之间。
  • 蓝色等级介于 0(蓝色)和 1(白色)之间。

我该怎么做?

【问题讨论】:

标签: r


【解决方案1】:

您可以使用colorRampPalette()(根据需要将"red" 替换为"blue""green"):

 ## Matrix from ?image
 x <- y <- seq(-4*pi, 4*pi, len = 27)
 r <- sqrt(outer(x^2, y^2, "+"))

 ## Plot it using a palette of your choice
 image(z = z <- cos(r^2)*exp(-r/6), 
       col  = colorRampPalette(c("white", "red"))(64))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-31
    • 2014-08-26
    • 2011-10-28
    • 2017-08-19
    • 1970-01-01
    • 2017-07-09
    • 2020-06-10
    相关资源
    最近更新 更多