[英]Creating Sankey Diagram using ggplot2, plotly and ggplotly
I want to create a sankey diagram using ggplot2 and plotly and call using ggplotly. 我想使用ggplot2创建一个sankey图并进行绘图,然后使用ggplotly进行调用。 I would require some good working examples with some crucial links.I have implemented one in plotly and this is the snap I achieved.
我需要一些关键链接的良好工作示例。我已经密谋实现了这一点,这就是我所实现的。 Please help and thanks.
请帮忙,谢谢。
Editing the script: 编辑脚本:
library(googleVis)
datSK <- data.frame(From=c(rep("r1","r2","r3","r4","r5","r6","r7")),
To=c(rep(c("Blood Test", "Check Out", "Discuss Results","MRI SCAN",
"Registration","Triage and Assessment","XRay"))),
Weight=c(237,492,495,236,500,500,261))
Sankey <- gvisSankey(datSK, from="From", to="To", weight="Weight",
options=list(
sankey="{link: {color: { fill: '#d799ae' } },
node: { color: { fill: '#a61d4c' },
label: { color: '#871b47' } }}"))
plot(Sankey)
This question is extremely old now and this answer wasn't around then, but the ggforce package now allows for sankey diagrams to be plotted in ggplot. 这个问题现在已经非常老了,这个答案还没有出现,但是ggforce软件包现在允许在ggplot中绘制sankey图。 There is currently no ggplotly support (and as such no interactablilty) but for simple sankeys it is now the best option I have found in that it works with the tidy data framework.
目前尚无ggplotly支持(因此也没有交互功能),但对于简单的sankeys,这是我发现的最佳选择,因为它可与整洁的数据框架一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.