Hi All,
Is there any suggestion to prepare the heatmap in the following figure with R? Thanks
By the way, How to control the color in the way as the figure.
Hi All,
Is there any suggestion to prepare the heatmap in the following figure with R? Thanks
By the way, How to control the color in the way as the figure.
This looks like the rotated lower/upper part of a square matrix. You can get the upper part of the matrix with something like
matrix[lower.tri(matrix)] <- NA
heatmap(matrix)
I am not sure how to rotate the image in R but you could always export it and rotate it with the GIMP or Inkscape. If other elements were to be added like in your example figure, I would export the heatmap and do the final figure assembly (including the rotation) in Inkscape.
Edit: You can rotate an image in R with rasterImage(). Something like this might work:
# create empty plot area first, d is the size of the matrix diagonal
plot(NA, type="n", xlim=c(0, d), ylim=c(0, d), xlab="", ylab="", asp=1)
rasterImage(as.raster(matrix),angle=45)
library("grDevices")
plot(1:20,pch=20,col=col)
col=colorRampPalette(c("white", "red"))(20)
M <- matrix(runif(100),10,10)
M[lower.tri(M)] <- NA
image(M,col = col,frame=F,xaxt="n",yaxt="n")
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Hi I am trying to the get the lower part of the square matrix (, but it didn't turn out to be a perfect triangular matrix, may I know what should I do? Thanks.