简体   繁体   English

绘图比率作为R中的相关矩阵

[英]Plot ratios as correlation matrix in R

This question is similar to me as this SO post. 这个问题跟我这个SO帖子类似

Sample data for the ratios: 比率的样本数据:

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))

To name the ratios: 命名比率:

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

so the y-axis labels are c(a,c,e,g,i) and x-axis c(b,d,f,h,j) 所以y轴标签是c(a,c,e,g,i)和x轴c(b,d,f,h,j)

Now, let's say the current measured values are: 现在,让我们说当前的测量值是:

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

Now, I would like to plot the measured value within each domain (ratio1, ratio2...etc.) as the referenced SO post about plotting correlation matrix. 现在,我想绘制每个域内的测量值(比率1,比率2 ......等)作为关于绘制相关矩阵的参考SO帖子。

So I would like to express the current measured value position within the interval in a color (from green to red, where red means the the upper limit has been reached) 所以我想用颜色表示区间内的当前测量值位置(从绿色到红色,其中红色表示已达到上限)

I would like to have the 5 ratios plotted as the correlation matrix referenced here. 我想将5个比率绘制为此处引用的相关矩阵。 Where each square would represent state of the measured value (via its color). 每个方块代表测量值的状态(通过其颜色)。

在此输入图像描述

I have tried to combine the boxplot bwplot and the lattice levelplot but unsuccessfully. 我试图将bwplot和晶格levelplot图组合在一起,但没有成功。

Hope the above makes sense. 希望以上是有道理的。 Please post any question you may have regarding the description above. 如果您对上述说明有任何疑问,请发布。

It's pretty hard to tell what you want to do here, but this could get you started 很难说出你想在这里做什么,但这可以让你开始

# 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)

Gives you something this: 给你这样的东西:

图

So your job would be to make z and modify the code, etc. 所以你的工作就是制作z并修改代码等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM