This continues a few comments that we exhanged off-github; I'm having difficulty providing an element_marquee() with a programatically generated list of grobs.
From the code below, I'd like to render the pts$foo grob in the text.
library(marquee)
library(ggplot2)
library(grid)
# Populate element
el <- ggplot2:::combine_elements(element_marquee(), theme_get()$text)
txt <- "Here be ![](foo) a point"
pts <- list(foo = pointsGrob(0.5, 0.5, default.units = "npc"))
expr <- rlang::expr(element_grob(el, label = txt))
For clear reasons, this wouldn't work out of the box, as the desired grob is in a list somewhere, not the current environment.
After some trial and error, what I found that did work was to use a local environment. This is fine for my purposes, but I'd prefer it if there were an easier way to do this.
Hi Thomas,
This continues a few comments that we exhanged off-github; I'm having difficulty providing an
element_marquee()
with a programatically generated list of grobs.From the code below, I'd like to render the
pts$foo
grob in the text.For clear reasons, this wouldn't work out of the box, as the desired grob is in a list somewhere, not the current environment.
Your suggestion at the time, to use a data mask does not work as I had hoped.
Neither does providing the grobs as the
env
argument.After some trial and error, what I found that did work was to use a local environment. This is fine for my purposes, but I'd prefer it if there were an easier way to do this.
Created on 2024-06-01 with reprex v2.1.0