Plotting a heat map for an upper or lower triangular matrix

前端 未结 1 965
别跟我提以往
别跟我提以往 2021-02-08 01:28

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

相关标签:
1条回答
  • 2021-02-08 01:50

    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:

    enter image description here

    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.

    0 讨论(0)
提交回复
热议问题