简体   繁体   English

R-Riverplot软件包使用-Sankey图

[英]R - Riverplot package uses - Sankey diagram

I try to draw a sankey chart using riverplot package by January. 我尝试在一月份之前使用riverplot包绘制一个sankey图表。 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! 非常感谢你!

在此处输入图片说明

在此处输入图片说明

My cases is difficult to generate a sample yet I reuse January sample included in riverplot package with some modification. 我的案例很难生成样本,但是我使用了经过一些修改后重用了Riverplot软件包中包含的一月份样本。 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)

Is the srt argument to riverplot plus shorter labels the answer? riverplot加上较短标签的srt参数是否是答案?

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)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM