不完全確定這是你想要的,但也許會讓你有一些方法。
這個想法是首先從你的數據形成一個邊緣列表,然後創建一個鄰接矩陣然後繪圖。
library(igraph)
library(Rgraphviz)
# your data
lst <- list(c(10,2,1), c(10,28,1), c(10,6,9), c(10,24,9), c(10,28,9))
# create edge list (from in first column/to in the second)
d <- do.call(rbind, lst)
edges <- rbind(d[,1:2], d[,2:3])
# get adjacency matrix
g <- graph.data.frame(edges, directed=TRUE)
adj <- as.matrix(get.adjacency(g))
# convert to a graph object and plot
g2 <- new("graphAM", adjMat=adj, edgemode="directed")
plot(g2, attrs = list(graph = list(rankdir="LR"),
node = list(fillcolor = "lightblue")))
rankdir="LR"
曲線圖從左至右
![enter image description here](https://i.stack.imgur.com/XIg5R.png)
以上小區採用dot
給予嚴格的結構。
編輯
使用layout = layout.reingold.tilford
使用igraph
E(g)$curved <- 0
plot.igraph(g, vertex.size=30, layout=layout.reingold.tilford)
得到一個樹形結構,我想我誤刪@的Gabor-csardi答案。有沒有辦法恢復它? – jcredberry