1

I have been looking through alluvial plots in r on Stack Overflow and all of the ones I see are either horizontal or vertical but not circular. Does anyone know if this is possible to do in r? So far the code i've been working on has just led me to a horizontal plot and my goal is to show how all these species are under the same label, but in the horizontal that is not expressed clearly.

Here is some example data:

  Sample Species   Label
1    L1      Fish    Seafood
2    L2      Shark   Seafood
3    L3      Fish    Seafood
4    L4      Crab    Seafood
5    L5      Crab    Seafood
6    L6      Shark   Seafood
7    L7      Seal    Seafood
8    L8      Crab    Seafood
9    L9      Fish    Seafood
10   L0      Fish    Seafood

Code I have been working on:

ggplot(data = Sample.ID,
       aes(axis1 = Sample, axis2 = Species, axis3 = Label)) +
  scale_x_discrete(limits = c("Sample", "Species", "Label"), expand = c(.2, .05)) +
  xlab("Classification") +
  geom_alluvium(aes(fill = Species)) +
  theme_minimal() +
  ggtitle("Sample to Species to Label")

Which gives me a plot like this plot output

I would like a plot that looks like this, so that the thickness of the line emphasizes how many fall under the same label. enter image description here

If anyone has any tips on how to create a circular plot in ggplot that would be incredibly helpful! Or any tips on how to more clearly express they are all falling under the same category. Thank you!

4
  • I don't understand the desired output. What would a circular alluvial plot look like? Do the colors just abruptly reset at some point in the circle? Do you have an example you can point to that shows what your desired result is?
    – MrFlick
    Commented Dec 5, 2022 at 21:38
  • Yes I will add an example! thank you!
    – IzOss
    Commented Dec 5, 2022 at 21:45
  • 3
    Are you looking for a so called Chord diagram? r-charts.com/flow/chord-diagram
    – deschen
    Commented Dec 5, 2022 at 21:45
  • Ooo that may work for what I am looking for! Thank you!
    – IzOss
    Commented Dec 5, 2022 at 21:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.