1

我有以下数据,我可以像这样可视化

A = matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 2, 1, 5, 6, 3, 4, 9, 10, 7, 8, 12, 11, 3, 5, 1, 7, 2, 9, 4, 11, 6, 12, 8, 10, 4, 6, 7, 8, 9, 10, 11, 1, 12, 2, 3, 5, 5, 3, 2, 9, 1, 7, 6, 12, 4, 11, 10, 8, 6, 4, 9, 10, 7, 8, 12, 2, 11, 1, 5, 3, 7, 9, 4, 11, 6, 12, 8, 3, 10, 5, 1, 2, 8, 10, 11, 1, 12, 2, 3, 4, 5, 6, 7, 9, 9, 7, 6, 12, 4, 11, 10, 5, 8, 3, 2, 1, 10, 8, 12, 2, 11, 1, 5, 6, 3, 4, 9, 7, 11, 12, 8, 3, 10, 5, 1, 7, 2, 9, 4, 6, 12, 11, 10, 5, 8, 3, 2, 9, 1, 7, 6, 4),nrow=12,ncol=12,byrow=TRUE)
require(plotrix)
color2D.matplot(A)

A可以是任何整数方阵)

我需要让它以不太相似的随机颜色显示。这是我要实现的目标的示例:

在此处输入图像描述

我一直无法让随机颜色起作用。matplot 是这个功能吗?谁能告诉我如何随机化颜色?

4

1 回答 1

1

根据@DWin 的评论,请尝试:

plot(NULL, type= "n", xlim = c(1,ncol(A)), ylim = c(1, nrow(A)), xlab = "column", ylab = "row",
  main = "HCL colors, pseudo-random hue, scaled chroma and luminance")
rect(col(A)-.5,row(A)-.5,col(A)+.5,row(A)+.5,
     col = hcl(h = round(runif(length(A))*360), c = 60*A/max(A)+20, l = 60*A/max(A)+20)
    )

在此处输入图像描述

我猜您仍然希望矩阵中的值仍然确定颜色的“暗度”,就像灰度图像中的情况一样。这里唯一随机的是色调——即从色轮中随机选取的角度。

于 2013-01-11T01:02:07.570 回答