R:对数刻度中的图像强度

时间:2016-07-28 04:58:44

标签: r image plot

我有一个概率矩阵:

x <- matrix(runif(16384), ncol = 128)
image(x)

现在,我希望x(图像强度代表&#34;概率&#34;)以对数刻度成像。

任何简单的建议?

1 个答案:

答案 0 :(得分:3)

image允许使用breaks参数灵活设置着色断点。您可以根据对数刻度设置颜色中断:

library(viridis) # you don't need this package, I'm just using it for color palette

colorBreaks = 10^(seq(-6, 0, by = 1)) # set color breaks however you want

image(x, breaks = colorBreaks, col = rev(magma(length(colorBreaks) - 1L)))
# use whatever color palette you want.  I used magma() from viridis

必须多一个休息而不是颜色,这就是我将-1L放入col = rev(inferno(length(colorBreaks) - 1L))的原因 enter image description here