Dear List,
I want to draw a Sankey-diagramm in R, for which I would use the
riverplot package.
It would be really nice to be able to
1. draw vertical lines (="edges") between nodes on the same x-axis
(T03-T04 in the example below) and
2. to invert the plot.
Now the "edge" between T03 and T04 is straight, but not vertical (1.).
I could invert the plot manually after drawing it, but there could
most likely be a more elegant solution (2.).
Any ideas would be appreciated.
Thank you,
Christian
library(riverplot)
trplot <- function ()
{
ret <- list(nodes = data.frame(ID =
c("T01","T02","T03","T04"),
x = c(1,2,3,3),
labels =
c("T1","T2","T3","T4"),
stringsAsFactors = FALSE),
styles = list(T01 = list(col = "red",lty = 0, textcol =
"white"),
T02 = list(col = "blue",lty = 0, textcol =
"white"),
T03 = list(col = "green",lty = 0, textcol
= "white"),
T04 = list(col = "cyan",lty = 0, textcol
"white")))
ret$edges <- data.frame(stringsAsFactors = FALSE,
N1 =
c("T01","T02","T03"),
N2 =
c("T03","T03","T04"),
Value=c(5,5,12))
rownames(ret$nodes) <- ret$nodes$ID
class(ret) <- c(class(ret), "riverplot")
return(ret)
}
style2 <- default.style()
style2[["edgestyle"]] <- "straight"
riverplot(trplot(),default_style=style2)