第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

R中的Sankey圖?

R中的Sankey圖?

明月笑刀無情 2019-12-10 10:53:24
我正在嘗試使用R中的Sankey Diagram可視化我的數(shù)據(jù)流。我發(fā)現(xiàn)此博客文章鏈接到生成Sankey Diagram的R腳本,不幸的是,它是原始的并且有點(diǎn)受限制(請參見下面的示例代碼和數(shù)據(jù))。有誰知道其他腳本,或者甚至是軟件包,它們更發(fā)達(dá)?我的最終目標(biāo)是通過圖表組件的相對大小來可視化數(shù)據(jù)流和百分比,就像這些Sankey Diagrams示例一樣。我在r-help列表上發(fā)布了一個類似的問題,但是兩周后沒有任何回應(yīng),我在這里嘗試了我的運(yùn)氣。謝謝,埃里克PS。我知道Parallel Sets Plot,但這不是我想要的。# thanks to, https://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/  sourc.https     <- function(url, ...) {# install and load the RCurl package if (match('RCurl', nomatch=0, installed.packages()[,1])==0) {  install.packages(c("RCurl"), dependencies = TRUE)  require(RCurl)  } else require(RCurl)    # parse and evaluate each .R script  sapply(c(url, ...), function(u) {    eval(parse(text = getURL(u, followlocation = TRUE,     cainfo  = system.file("CurlSSL", "cacert.pem",     package = "RCurl"))), envir = .GlobalEnv) } ) }# from https://gist.github.com/1423501sourc.https("https://raw.github.com/gist/1423501/55b3c6f11e4918cb6264492528b1ad01c429e581/Sankey.R")# My example (there is another example inside Sankey.R):inputs = c(6, 144)losses = c(6,47,14,7, 7, 35, 34)unit = "n ="labels = c("Transfers",           "Referrals\n",           "Unable to Engage",           "Consultation only",           "Did not complete the intake",           "Did not engage in Treatment",           "Discontinued Mid-Treatment",           "Completed Treatment",           "Active in \nTreatment")SankeyR(inputs,losses,unit,labels)# Clean up my messrm("inputs", "labels", "losses", "SankeyR", "sourc.https", "unit")用以上代碼生成的Sankey圖, 用上面的代碼生成的Sankey圖
查看完整描述

3 回答

?
翻閱古今

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超5個贊

如果您想使用R進(jìn)行操作,則最好的出價似乎是@Roman建議- 修改SankeyR函數(shù)。例如,下面是我的快速解決方法,只需將標(biāo)簽垂直放置,適當(dāng)?shù)仄扑鼈儾p少輸入引用的字體,以使其看起來更好。此修改僅更改SankeyR函數(shù)中的行171和223 :


    #line171 - change oversized font size of input label

    fontsize = max(0.5,frInputs[j]*1.5)#1.5 instead of 2.5 


    #line223 - srt changes from 35 to 90 to orient labels vertically, 

    #and offset adjusts them to get better alignment with arrows

    text(txtX, txtY, fullLabel, cex=fontsize, pos=4, srt=90, offset=0.1)

在此處輸入圖片說明


我不是三角學(xué)的王牌,但這確實(shí)是改變箭頭方向所需要的。在我看來,這是理想的選擇-如果您可以調(diào)整松動箭頭,使它們水平而不是垂直。否則,為什么我的解決方案解決了標(biāo)簽方向問題,但并沒有使圖表更具可讀性...


查看完整回答
反對 回復(fù) 2019-12-10
  • 3 回答
  • 0 關(guān)注
  • 685 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號