I realized this graph using ggplot2 and I\'d like to change y axes to percentages, from 0% to 100% with breaks every 10. I know I can use:
+ scale_y
Using the scale argument in percent_format this can be achieved like so:
PIPPO <- data.frame("ID"=rep(c(1:20),2), "time"=c(rep(1,20),rep(2,20)), "value"=c("B","G","B","G","B",rep("G",3),rep("B",2),"G",rep("B",3),"G",rep("B",6),"G","B","G","B",rep("G",3),rep("B",2),"G",rep("B",3),"G","B","switch",rep("B",2),"switch"))
library(ggplot2)
library(ggalluvial)
n_id <- length(unique(PIPPO$ID))
ggplot(PIPPO,
aes(x = time, stratum = value, alluvium = ID,
fill = value, label = value)) +
scale_fill_brewer(type = "qual" , palette = "Set3") +
scale_y_continuous(label = scales::percent_format(scale = 100 / n_id)) +
geom_flow(stat = "flow", knot.pos = 1/4, aes.flow = "forward", color = "gray",) +
geom_stratum() +
theme(legend.position = "bottom")

Created on 2020-05-19 by the reprex package (v0.3.0)