簡體   English   中英

使用ggplot2和ggplotly創建Sankey Diagram

[英]Creating Sankey Diagram using ggplot2, plotly and ggplotly

我想使用ggplot2創建一個sankey圖並進行繪圖,然后使用ggplotly進行調用。 我需要一些關鍵鏈接的良好工作示例。我已經密謀實現了這一點,這就是我所實現的。 請幫忙,謝謝。

編輯腳本:

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)

桑基

這個問題現在已經非常老了,這個答案還沒有出現,但是ggforce軟件包現在允許在ggplot中繪制sankey圖。 目前尚無ggplotly支持(因此也沒有交互功能),但對於簡單的sankeys,這是我發現的最佳選擇,因為它可與整潔的數據框架一起使用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM