I have a matrix with some correlation values. Now I want to plot that in a graph that looks more or less like that:

Login

0 votes

To plot a correlation matrix on a graph, you can use the **lattice **package as follows:

To create the information for the horizontal and vertical axis.

library(lattice)

hori <- c("214", "215", "216", "224", "211", "212", "213", "223", "226", "225")

vert <- paste("DM1-", hori, sep="")

To build a dummy correlation matrix

nrowcol <- length(vert)

cor <- matrix(runif(nrowcol*nrowcol, min=0.4), nrow=nrowcol, ncol=nrowcol, dimnames = list(hori, vert))

for (i in 1:nrowcol) cor[i,i] = 1

To plot the matrix

rgb.palette <- colorRampPalette(c("blue", "yellow"), space = "rgb")

levelplot(cor, main="stage 12-14 array correlation matrix", xlab="", ylab="", col.regions=rgb.palette(120), cuts=100, at=seq(0,1,0.01))

Output: