I am using ggalluvial to make a plot in RStudio.
I have tried everything, but for the life of me I can not get the last two axis in the correct order. I want axis3 to be ordered "0, 2, 3" and axis4 to be ordered "low, int, high".
[
I have set factor levels for all axes as follows:
df$axis3_score <- factor(df$axis3_score,
levels = c("0", "2", "3"))
But no matter what I try, it simply does not work. Here is the code to my plot:
ggplot(df,
aes(axis1 = axis1_score,
axis2 = axis2_score,
axis3 = axis3_score,
axis4 = axis4_score,
y = total_score)) +
geom_flow(aes(fill = int_score, order = as.numeric(int_score)), width = 0.2) +
geom_stratum(width = 0.2, fill = "grey") +
geom_text(stat = "stratum", aes(label = after_stat(stratum))) +
scale_x_discrete(limits = c("axis1", "axis2", "axis3", "axis4"), expand = c(.1, .1)) +
theme_minimal()
I'm afraid I can't post my data. I hope you can help anyways. Thanks!