0

Two questions of R circlepack plot :

  1. the result always not real circular (it always show in ellipse, I have to adjust the plot window size in Rstudio ....) . Is the any way to hadle it ?

  2. The position of circular and sub circular will be changed when rerun the code ? How to fix it ?

    library(ggraph)
     library(igraph)
     library(dplyr)
     library(tidyverse)
    
     md <- data.frame(category = c('FDM','FDM','FDM','LCD','LCD','LCD'),
                           item =c('A1','B1','C1','A','B','C'),
                      amount = c(1,2,3,4,3,1))
     md_sum <- md %>% group_by(category) %>% summarise(amount =sum(amount)) %>% rename('item'='category')
    
     md_v <- rbind(md[,c(2:3)],md_sum)
    
     pt <- igraph::graph_from_data_frame(md,vertices = md_v)
    
    
     ggraph(pt,layout = 'circlepack', weight =amount)+
       geom_node_circle(aes(fill=depth))+
      geom_node_label(aes(label = paste0(name,'\n',amount )))+theme_void()
    

enter image description here

anderwyang
  • 1,801
  • 4
  • 18

0 Answers0