0

这个问题与我的这个SO 帖子相似。

比率的样本数据:

n=50
ratio1 <- seq(0,1.5,(1.5-0)/(n-1))
ratio2 <- seq(0,2.5,(2.5-0)/(n-1))
ratio3 <- seq(0.5,4.5,(4.5-0.5)/(n-1))
ratio4 <- seq(1,3,(3-1)/(n-1))
ratio5 <- seq(0.7,2,(2-0.7)/(n-1))

要命名比率:

rname <- c("a/b","c/d","e/f","g/h","i/j") 

所以y轴标签是c(a,c,e,g,i)和x轴c(b,d,f,h,j)

现在,假设当前测量值为:

measure.r <- data.frame(c(0.7,1.5,3.3,2.5,1.5))
colnames(measure.r) <- C("r1","r2","r3","r4","r5")

现在,我想绘制每个域(ratio1、ratio2 等)内的测量值作为关于绘制相关矩阵的参考 SO 帖子。

所以我想用一种颜色来表示当前测量值在区间内的位置(从绿色到红色,其中红色表示已达到上限)

我想将 5 个比率绘制为此处引用的相关矩阵。其中每个方块将代表测量值的状态(通过其颜色)。

在此处输入图像描述

我试图将箱线图bwplot和格子结合起来,levelplot但没有成功。

希望以上是有道理的。请发布您可能对上述描述有任何疑问。

4

1 回答 1

2

很难说你想在这里做什么,但这可以让你开始

# some fake data
n <- 5
x <- y <- seq_len(n)
z <- outer(x, y, "/")*rnorm(n) # create a matrix of values

# color palette function
pal <- colorRampPalette(c("green", "red"))

# setup plotting regions
layout(matrix(1:2), heights=c(0.7,0.3))

# make an image of the matrix
# ("n" turns off the axis labeling)
image(x, y, z, xaxt="n", yaxt="n", col=pal(11), asp=1, pty="s")
axis(1, x, letters[1:5])
axis(2, y, letters[6:10])

# add a cheap colorbar...
cz <- pretty(range(z))
cx <- seq_along(cz)
image(x=cx, z=matrix(cz), xaxt="n", yaxt="n", col=pal(11))
axis(1, cx, cz)

给你这样的东西:

图

所以你的工作是制作z和修改代码等。

于 2013-10-16T22:04:50.593 回答