1. library(ggplot2)
    2. library(ggalluvial)
    3. library(RColorBrewer)
    4. color = brewer.pal(n = 2, 'Set2')
    5. ggplot(data, aes(axis1 = axis1, axis2 = axis2, y = Freq))+
    6. geom_alluvium(aes(fill = axis3))+
    7. scale_x_discrete(limits = c("axis1", 'axis2'),
    8. expand = c(.1, .05),
    9. )+
    10. geom_stratum()+geom_text(stat = "stratum", aes(label = after_stat(stratum)))+
    11. theme_minimal()+
    12. theme_classic()+
    13. scale_fill_manual(values = c("#66C2A5", "#FC8D62"))

    note: data整理为
    image.png
    图还是很漂亮的~
    image.png