Reproducing lattice dendrogram graph with ggplot2

前端 未结 4 1303
一个人的身影
一个人的身影 2020-11-28 21:49

Is this possible to reproduce this lattice plot with ggplot2?

library(latticeExtra)
data(mtcars)
x  <- t(as.matrix(scale(mtcars)))
dd.row <- as.dendrog         


        
4条回答
  •  伪装坚强ぢ
    2020-11-28 22:06

    As Ben says, everything is possible. Some work to support dendrograms has been done. Andrie de Vries has made a fortify method of tree objects. However, the resulting graphic is not pretty as you can see.

    The tile would be easy to do. For the dendrogram I would inspect plot.dendrogram (using getAnywhere) to see how the coordinates for the segments are calculated. Extract those coordinates and use geom_segment to plot the dendrogram. Then use viewports to plot the tiles and the dendrogram together. Sorry I can't give a example, it's a lot of work and it's too late.

    I hope this helps

    Cheers

    dendrogram

提交回复
热议问题