# NOT RUN {
# full axis width
ggplot(as.data.frame(Titanic),
aes(y = Freq,
axis1 = Class, axis2 = Sex, axis3 = Age, axis4 = Survived)) +
geom_stratum(width = 1) + geom_text(stat = "stratum", infer.label = TRUE) +
scale_x_discrete(limits = c("Class", "Sex", "Age", "Survived"))
# use of facets
ggplot(as.data.frame(Titanic),
aes(y = Freq,
axis1 = Class, axis2 = Sex)) +
geom_flow(aes(fill = Survived)) +
geom_stratum() + geom_text(stat = "stratum", infer.label = TRUE) +
scale_x_discrete(limits = c("Class", "Sex")) +
facet_wrap(~ Age, scales = "free_y")
# }
Run the code above in your browser using DataLab