2

我正在使用riverplotR 中的包。我可以制作桑基图。我希望能够添加一个垂直标签(最好在底部)。我发现了一个似乎可以做到这一点的例子: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 )

在这里,我想在 and 下有一个标签,在Node Acalled下Node BLeft另一个标签。Node CRight

4

1 回答 1

2

这是一种方法:

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
)

在此处输入图像描述

于 2017-06-15T19:46:24.543 回答