ggh4x
ggh4x copied to clipboard
Add tag_facet function?
Would it be possible to swipe the tag_facet
function from egg
and incorporate it such that it plays nicely with facet_nested
?
I think the only thing that's needed is to take the current version:
tag_facet <- function(p, open = "(", close = ")", tag_pool = letters, x = -Inf, y = Inf,
hjust = -0.5, vjust = 1.5, fontface = 2, family = "", ...) {
gb <- ggplot_build(p)
lay <- gb$layout$layout
tags <- cbind(lay, label = paste0(open, tag_pool[lay$PANEL], close), x = x, y = y)
p + geom_text(
data = tags, aes_string(x = "x", y = "y", label = "label"), ..., hjust = hjust, vjust = vjust,
fontface = fontface, family = family, inherit.aes = FALSE) +
theme(strip.text = element_blank(), strip.background = element_blank())
}
and remove that last theme
line and then we get beautiful, automatically-labelled facets. I would consider this to be h4x and egg
hasn't been updated in 4 years