Plotting a heat map for an upper or lower triangul

2019-03-18 22:59发布

问题:

Can any body suggest a function to plot heat map for upper or lower triangular matrix in R

回答1:

The most basic way to do something like this would be using ?image as follows:

M <- matrix(runif(100),10,10)
M[lower.tri(M)] <- NA
image(1:10,1:10,M)

which would result in something like this:

You could also investigate the functions ?heatmap or in the gplots package ?heatmap.2. Doing this using ggplot2 using geom_tile is a little different but you can find some examples to walk you through the process here.