我有一个概率矩阵:
x <- matrix(runif(16384), ncol = 128)
image(x)
现在,我希望x(图像强度代表&#34;概率&#34;)以对数刻度成像。
任何简单的建议?
答案 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))
的原因