2

I try to draw a sankey chart using riverplot package by January. However my cases is quite complex and I haven't found way to fix my chart so I post this questions, hope this help either find some answer to my questions or way to improve the packages.

My charts as below. As you can see my chart in the 1st image have the node's status overlap each others and not readable. Is it possible to display the nodes name on the side of the chart, and each nodes name will next to the lane that it stand for. The ideas display in the second image below where we have multiple lanes and then the status should be on the side to explain what is lane mean.

Thank you very much!

enter image description here

enter image description here

My cases is difficult to generate a sample yet I reuse January sample included in riverplot package with some modification. Here it is

library(riverplot)
temp <- function () {
ret <- list(nodes = 
                data.frame(ID = LETTERS[1:8], x = c(1,2, 2, 3, 3, 4, 5, 1), 
                           labels = c(NA, NA, "Node C Node C Node C", rep(NA, 4), "Node H Node H Node H"), 
                           stringsAsFactors = FALSE), 
            styles = list(A = list(col = "#00990099",
                                   lty = 0, textcol = "white"), 
                          H = list(col = "#FF000099", textcol = "white"), 
                          B = list(col = "#00006699", textcol = "white"),                                                                                                                                                                           F = list(col = "yellow"), D = list(col = "#00FF0099")))
ret$edges <- data.frame(N1 = c("A", "A", "A", "H", "H", "H", 
                               "B", "B", "C", "C", "C"), N2 = 
                            c("B", "C", "D", "D", "F", "G", "D", "F", "D", "E", "F"), 
                        Value = c(10, 20, 5, 10, 10, 20, 5, 10, 20, 15, 10), stringsAsFactors = F)
rownames(ret$nodes) <- ret$nodes$ID
class(ret) <- c(class(ret), "riverplot")
return(ret)
} 
x <- temp(x) 
plot(x)
www
  • 38,575
  • 12
  • 48
  • 84
sinhnhn
  • 65
  • 1
  • 7
  • 2
    Can you please provide a [reproducible example](http://adv-r.had.co.nz/Reproducibility.html)? – lukeA Jul 25 '14 at 11:29
  • I reuse the standard sample within the riverplot package. The sample have Node C name overlap other node name which make it slightly difficult to read similar to my case but not exactly the same. – sinhnhn Jul 25 '14 at 11:47

1 Answers1

0

Is the srt argument to riverplot plus shorter labels the answer?

ret <- list(nodes = 
              data.frame(ID = LETTERS[1:8], x = c(1,2, 2, 3, 3, 4, 5, 1), 
    #                     labels = c(NA, NA, "Node C Node C Node C", rep(NA, 4), "Node H Node H Node H"), 
            labels = c(NA, NA, "Node C", rep(NA, 4), "Node H"), 
                         stringsAsFactors = FALSE), 
            styles = list(A = list(col = "#00990099",
                                   lty = 0, textcol = "white"), 
                          H = list(col = "#FF000099", textcol = "white"), 
                          B = list(col = "#00006699", textcol = "white")))                                                                                                                                                                           F = list(col = "yellow"), D = list(col = "#00FF0099")))
ret$edges <- data.frame(N1 = c("A", "A", "A", "H", "H", "H", 
                               "B", "B", "C", "C", "C"), N2 = 
                          c("B", "C", "D", "D", "F", "G", "D", "F", "D", "E", "F"), 
                        Value = c(10, 20, 5, 10, 10, 20, 5, 10, 20, 15, 10), stringsAsFactors = F)
rownames(ret$nodes) <- ret$nodes$ID
class(ret) <- c(class(ret), "riverplot")

riverplot(ret, srt = 0)

enter image description here

lawyeR
  • 7,488
  • 5
  • 33
  • 63