Plotting a heat map for an upper or lower triangular matrix
Can any body suggest a function to plot heat map for upper or lower triangular matrix开发者_JS百科 in R
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.
精彩评论