R使用riverplot的Sankey图-垂直标签
我正在R中使用R使用riverplot的Sankey图-垂直标签,r,label,sankey-diagram,riverplot,R,Label,Sankey Diagram,Riverplot,我正在R中使用riverplot包。我能够制作一个Sankey图。我想能够添加一个垂直标签(最好在底部)。我发现了一个这样的例子:(我指的是图20,在顶部附近-像2004和2015这样的标签是我试图弄清楚如何创建的) 我自己怎么做 这是一个MWE,直接取自 库(riverplot) 节点这里有一种方法: library(riverplot) nodes <- c( LETTERS[1:3] ) edges <- list( A= list( C= 10 ), B= list( C=
riverplot
包。我能够制作一个Sankey图。我想能够添加一个垂直标签(最好在底部)。我发现了一个这样的例子:(我指的是图20,在顶部附近-像2004
和2015
这样的标签是我试图弄清楚如何创建的)
我自己怎么做
这是一个MWE,直接取自
库(riverplot)
节点这里有一种方法:
library(riverplot)
nodes <- c( LETTERS[1:3] )
edges <- list( A= list( C= 10 ), B= list( C= 10 ) )
r <- makeRiver( nodes, edges, node_xpos= c( 1,1,2 ),
node_labels= c( A= "Node A", B= "Node B", C= "Node C" ),
node_styles= list( A= list( col= "yellow" )) )
(coords <- plot(r))
# A B C
# x 1 1 2
# top -22 -10 -20
# center -17 -5 -10
# bottom -12 0 0
text(
x = range(coords["x",]),
y = min(coords["top",]),
labels = c("left", "right"),
pos = 1, offset = 0, font = 2
)
库(riverplot)
节点
library(riverplot)
nodes <- c( LETTERS[1:3] )
edges <- list( A= list( C= 10 ), B= list( C= 10 ) )
r <- makeRiver( nodes, edges, node_xpos= c( 1,1,2 ),
node_labels= c( A= "Node A", B= "Node B", C= "Node C" ),
node_styles= list( A= list( col= "yellow" )) )
(coords <- plot(r))
# A B C
# x 1 1 2
# top -22 -10 -20
# center -17 -5 -10
# bottom -12 0 0
text(
x = range(coords["x",]),
y = min(coords["top",]),
labels = c("left", "right"),
pos = 1, offset = 0, font = 2
)