我正在使用R中的riverplot包,我能够制作一个Sankey图。我希望能够添加一个垂直标签(最好在底部)。我找到了一个这样做的例子:http://www.statsmapsnpix.com/2016/08/research-with-qgis-r-and-speaking-to.html (我指的是图20,靠近2004和2015这样的顶级标签,我正试图找出如何创建)。
我怎么才能自己做呢?
下面是一个MWE,直接取自https://cran.r-project.org/web/packages/riverplot/riverplot.pdf的包文档
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" )) )
plot( r )在这里,我希望在Node A和Node B下面有一个名为Left的标签,在Node C下有另一个标签叫做Right。
发布于 2017-06-15 19:46:24
有一种方法可以做到:
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
)

https://stackoverflow.com/questions/44574652
复制相似问题