【问题标题】:R Sankey Diagram using riverplot - Vertical Labels使用河图的 R 桑基图 - 垂直标签
【发布时间】:2017-06-15 18:39:12
【问题描述】:

我在 R 中使用riverplot 包。我能够制作桑基图。我希望能够添加一个垂直标签(最好在底部)。我发现了一个似乎可以做到这一点的例子:http://www.statsmapsnpix.com/2016/08/research-with-qgis-r-and-speaking-to.html(我指的是图 20,靠近顶部 - 我想弄清楚如何创建标签,如 20042015)。

我自己怎么做?

这是一个 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 ANode B 下创建一个名为Left 的标签,在Node C 下创建一个名为Right 的标签。

【问题讨论】:

    标签: r label sankey-diagram riverplot


    【解决方案1】:

    这是一种方法:

    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
    )
    

    【讨论】:

      猜你喜欢
      • 2021-06-20
      • 1970-01-01
      • 1970-01-01
      • 2016-04-06
      • 2012-04-15
      • 2018-10-18
      • 1970-01-01
      • 2020-09-25
      相关资源
      最近更新 更多