Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion: multiple annotations in a single at_panel #183

Open
dcousin3 opened this issue Jan 19, 2025 · 2 comments
Open

suggestion: multiple annotations in a single at_panel #183

dcousin3 opened this issue Jan 19, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@dcousin3
Copy link

Hello, Thanks for your function at_panel(), this is indeed a much needed tool.

Can I suggest that a list of annotations be possible in at_panel(). Here is an example:

p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  facet_grid(year ~ drv)

annotations <- list( 
    annotate("text", x = 3, y = 40, label = "My text"),
    annotate("segment", x = 3, y = 40, xend = 5, yend = 20, color="red")
)

# Target specific panels
p + at_panel(annotations, PANEL %in% c(2, 4))

That would be handy and help keep code cleaners when many annotations are needed in certain panels.

@teunbrand
Copy link
Owner

Thanks for the suggestion! I can see the merit and there isn't anything I can think of that prevents this. However, I don't know when I'll get around working on ggh4x again, so I can't make any promises on when this will be available.

@teunbrand teunbrand added the enhancement New feature or request label Jan 19, 2025
@dcousin3
Copy link
Author

Thanks. In the meanwhile, interested users can do something like:

p + lapply(annotations, \(ann) {at_panel(ann, PANEL %in% c(2, 4))})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants