This page follows the chart #314 that explained the basis of circle packing. We use the awesome ggraph library, and this page describes how to custom colour, size and others.

 

The first step is to map a feature of each circle to a specific size. This is quite straightforward using the ‘weight’ argument in the ggraph call:

 

 

 

Now, we definitely need to add color to the chart. The first option is to map color to depth: the origin of every node will have a color, the level 1 another one and so one. As usual, you can play with the colour palette to fit your needs. Here are 2 examples with the viridis and the RColorBrewer palettes:

 

 

To add more insight to the plot, we often need to add labels to the circles. However you can do it only if the number of circle is not to big. Note that you can use geom_node_text (left) or geom_node_label to annotate leaves of the circle packing:

 

 

Related


 

 

Make a search


 

 


2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
HoltzMaria Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Maria
Guest
Maria

I’m trying to replicate your cool graphs with my own data but running into problems when running it. The error is “Some vertex names in edge list are not listed in vertex data frame”. Seems it might have to do with the vertex list:

c(edges[,1], edges[,2]) %in% vertices
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[18] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[35] FALSE FALSE FALSE FALSE

Any help is appreciated.

Thanks,
Maria