【问题标题】:grid.ls only shows the top-level layoutgrid.ls 只显示顶层布局
【发布时间】:2018-06-23 04:41:28
【问题描述】:

我想使用gridSVG::grid.garnish 向我从 ggplot2 导出的 SVG 添加信息,但它一次只能在一个 grob 上工作——也就是说,您需要知道哪个 grob 是哪个。我理解I can use grid.ls to identify the structure of grobs in a plot,但是当我自己调用grid.ls 时,它只显示顶级布局:

library(tidyverse)
library(gridSVG)

p1 = quickplot(1:5, (1:5)^2)
p1g = ggplotGrob(p1)
grid.ls(p1g)
# layout

我尝试过使用不同的参数(如 recursive = TRUEfullNames = TRUE),以及各种不同的基于 ggplot 的绘图,但我总是只得到顶级的 layout(或者,使用 @987654330 @、gtable[layout])。我怎样才能看到孩子 grobs?

我在 macOS 上使用 ggplot2 v. 2.2.1.9000 和 gridSVG v. 1.6-0。

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    正文必须至少为 30 个字符

    grid.ls(grid.force(p1g))
    

    【讨论】:

    • ?grid.force: '一些grobs只在绘制时生成它们的内容来绘制;这个函数用它们在绘图时的内容替换了这些 grobs。谢谢yoooouuuuu
    • 请不要滥用“帖子太短系统”。相反,解释它为什么起作用
    猜你喜欢
    • 1970-01-01
    • 2017-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    • 1970-01-01
    • 2014-07-27
    • 1970-01-01
    相关资源
    最近更新 更多