58 lines
1.5 KiB
R
58 lines
1.5 KiB
R
|
|
|
||
|
|
grps <- rbind(c("low0","low6","1"),
|
||
|
|
c("high0","low6","2"),
|
||
|
|
c("low0","high6","3"),
|
||
|
|
c("high0","high6","4"))
|
||
|
|
|
||
|
|
tmes <- c(48,62,55,323)
|
||
|
|
|
||
|
|
tbl <- data.frame(grps,tmes)
|
||
|
|
|
||
|
|
colnames(tbl) <- c("t1","t2","grp","n")
|
||
|
|
|
||
|
|
library(ggalluvial)
|
||
|
|
|
||
|
|
cls <- viridisLite::turbo(4,direction=-1)
|
||
|
|
|
||
|
|
cls
|
||
|
|
stRoke::color_plot(viridisLite::turbo(4,direction=-1))
|
||
|
|
|
||
|
|
p <- ggplot(tbl,aes(y = n, axis1 = t1, axis2 = t2)) +
|
||
|
|
geom_alluvium(
|
||
|
|
aes(fill = grp, color = grp),
|
||
|
|
width = 1 / 16,
|
||
|
|
alpha = .6,
|
||
|
|
knot.pos = 0.4
|
||
|
|
) +
|
||
|
|
# geom_stratum(aes(size=10),width = 1 / 4,
|
||
|
|
# fill = box,
|
||
|
|
# color = border) +
|
||
|
|
# geom_text(stat = "stratum", aes(label = after_stat(stratum)), colour = "white", size = 20) +
|
||
|
|
scale_x_continuous(breaks = 1:2,
|
||
|
|
labels = c("Pre-stroke\nquartile", "Six months\nquartile")) +
|
||
|
|
scale_y_continuous(breaks=c(0,103,488))+
|
||
|
|
scale_fill_manual(values = cls) +
|
||
|
|
scale_color_manual(values = cls) +
|
||
|
|
# labs(title=NULL, legend=NULL)+
|
||
|
|
theme_minimal()
|
||
|
|
|
||
|
|
png(
|
||
|
|
filename = "sankey_change_WSC.png",
|
||
|
|
units = "mm",
|
||
|
|
width = 500,
|
||
|
|
height = 500,
|
||
|
|
pointsize = 15,
|
||
|
|
res = 300
|
||
|
|
); p+
|
||
|
|
theme_minimal() +
|
||
|
|
theme(
|
||
|
|
legend.position = "none",
|
||
|
|
panel.grid.major = element_blank(),
|
||
|
|
panel.grid.minor = element_blank(),
|
||
|
|
axis.text.y = element_blank(),
|
||
|
|
axis.title.y = element_blank(),
|
||
|
|
axis.text.x = element_blank(),
|
||
|
|
plot.title = element_blank(),
|
||
|
|
panel.background = element_rect(fill='transparent'),
|
||
|
|
plot.background = element_rect(fill='transparent', color=NA)
|
||
|
|
); dev.off()
|