简体   繁体   中英

Zoom and plot only specific node for a given dendogram

Hi suppose I generated a dendogram as such:

library(dendextend)
library(tidyverse)
mtcars %>% 
    select(mpg, cyl, disp) %>% 
    dist() %>% 
    hclust() %>% 
    as.dendrogram() -> dend

dend %>% 
    set("nodes_pch", 19)  %>% 
    set("nodes_cex", 0.7) %>% 
    set("nodes_col", "orange") %>% 
    plot()

I want to keep this dendogram but zoom in on one of the node and replot without rerunning the distance and hclust. Is this possible Here is an image of where I want to cut and replot.

在此处输入图片说明

You could specify the area in which you would like to zoom in using the xlim and ylim arguments in plot . For example, the node you are interested in plotting is found between x-axis positions 4 and 7 (position from left to right) and y-axis positions 0 and 10.

dend %>% 
  set("nodes_pch", 19)  %>% 
  set("nodes_cex", 0.7) %>% 
  set("nodes_col", "orange") %>% 
  plot(xlim = c(4,7),
       ylim = c(0,10))

放大的丹卓

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM