Data
library(tidyverse)
library(ggalluvial)
test <- structure(list(A = c("CORBMI", "PLRV00", "PSTVD0", "MONIFC",
"LEPGWA", "CLRV00", "CHTSFR", "ERWICD", "MELMME", "PHYPPN"),
B = c(0.42784719084056, 0.285120867173756, 0.261137015606322,
0.254778215312991, 0.212680830980426, 0.186122557236353,
0.124216122036791, 0.124216122036791, 0.115530651882571,
0.109646238427031), C = c(0.756907014898909, 0.949604769547122,
0.756907014898909, 0.384778775205252, 0.257514393423948,
0.700112035900806, 0.257514393423948, 0.257514393423948,
0.384778775205252, 0.165593221053012), D = c(0.565257267298153,
0.300252143120273, 0.345005410791706, 0.662142071576284,
0.825898809587267, 0.265846818355118, 0.482365744241307,
0.482365744241307, 0.300252143120273, 0.662142071576284)), row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"))
Problem
I am attempting to make an alluvial plot, but I ma having problems with the ordering and reordering the axis. Also, I wish to space the y-axis equally - now they get smaller and smaller as the numbers decrease. The most important thing is that column A is sorted according to column B, and that the other columns are in descending order. But I am also struggling with the labeling and spacing of the "boxes" in each axis is spaced equally and not according to the size of the value. I have tried different thing, e.g., making factors and factor levels but without luck..
example code
ggplot(test, aes(y = B, axis1=-B, axis2=-reorder(C, -B), axis3=reorder(D, -B))) +
geom_alluvium(aes(fill = A), width = 1/12) +
geom_stratum(width = 1/12, color = "grey")+
geom_text(stat = "stratum", aes(label = A))