Reputation: 2067
I want to use gridSVG::grid.garnish
to add information to SVGs I export from ggplot2, but it only works on one grob at a time—that is to say, you need to know which grob is which. I understanding that I can use grid.ls
to identify the structure of grobs in a plot, but when I call grid.ls
myself, it only shows the top-level layout:
library(tidyverse)
library(gridSVG)
p1 = quickplot(1:5, (1:5)^2)
p1g = ggplotGrob(p1)
grid.ls(p1g)
# layout
I've tried using different arguments (like recursive = TRUE
and fullNames = TRUE
), and also a variety of different ggplot-based plots, but I invariably only get the top-level layout
(or, with fullNames = TRUE
, gtable[layout]
). How can I see the child grobs?
I'm using ggplot2 v. 2.2.1.9000 and gridSVG v. 1.6-0 on macOS.
Upvotes: 2
Views: 230
Reputation: 42
Use grid.force
("Some grobs only generate their content to draw at drawing time; this function replaces such grobs with their at-drawing-time content."):
grid.ls(grid.force(p1g))
Upvotes: 1