I am trying to great a chord diagram that reflects a 3 way connection that goes from the individual sample to species to what label it falls under. However when I try to create my chord diagram some of my labels are overlapping and you cant see what is each part. This doesn't happen when I use a smaller sample amount like 20, but I have a large data set of 40 which leads to overlap. Also my third label "seafood" does not show up at all and just disappears when I want to show that all those species fall under same label
The example data I have is:
Sample Species Label
L1 Shark Seafood
L2 Tuna Seafood
L3 Shark Seafood
L4 Shrimp Seafood
L5 Crab Seafood
L6 Tuna Seafood
L7 Shrimp Seafood
L8 Shark Seafood
L9 Shark Seafood
L10 Crab Seafood
L11 Tuna Seafood
L12 Shrimp Seafood
L13 Crab Seafood
L14 Crab Seafood
L15 Shark Seafood
L16 Tuna Seafood
L17 Tuna Seafood
L18 Shark Seafood
L19 Shark Seafood
L20 Shrimp Seafood
L21 Shark Seafood
L22 Tuna Seafood
L23 Shark Seafood
L24 Shrimp Seafood
L25 Crab Seafood
L26 Tuna Seafood
L27 Shrimp Seafood
L28 Shark Seafood
L29 Shark Seafood
L30 Crab Seafood
L31 Tuna Seafood
L32 Shrimp Seafood
L33 Crab Seafood
L34 Crab Seafood
L35 Shark Seafood
L36 Tuna Seafood
L37 Tuna Seafood
L38 Shark Seafood
L39 Shark Seafood
L40 Shrimp Seafood
The code I have is: library(circlize)
col.pal = c(Sample.= "blue", Species = "red", Label = "green")
chordDiagram(Example, grid.col = col.pal)
What I would like to get is this where there is a third spot where all the lines from species would then connect to the seafood and all labels are visible:
Please let me know any tips! I am totally new to chord diagrams and pretty new to coding so im sure im missing something. I saw some people use matrices for their chord diagrams but when I tried to do this i received error: "error non-numeric argument to mathematical function".
I'm not sure a chord diagram is right for this sort of relationship, even if it is pretty. Essentially it sounds like you want a hierarchical graph (i.e. a tree structure). You can still get this to be attractive, colorful and even circular. Here's an example using your data and the
tidygraph
andggraph
packages: