Closed Aariq closed 1 year ago
If you wrap a text annotation, it's not that cumbersome to achieve similar effects. The -Inf
and Inf
positions place it in the corner.
library(ggplot2)
place_label <- function(label, size = 5, ...) {
annotate("text", label = label, x = -Inf, y = Inf,
hjust = 0, vjust = 1, size = size, ...)
}
p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp))
p1 + place_label("a)")
Created on 2021-01-09 by the reprex package (v0.3.0)
Wow, thank you! I had no clue you could pass Inf
as a position like that.
I also came into this issue and made a package: tagger. It's not perfect, but it might be useful!
library(tagger)
library(ggplot2)
ggplot(mtcars, aes(hp, mpg)) +
geom_point() +
facet_grid(cyl ~ vs) +
tag_facets()
I think the main benefit of having it as a proper part of the tag element is that it will allow patchwork to use the position for auto tagging
I think adding a setting such as plot.tag.position
would be nicely aligned with how positioning of titles currently work
Some peer-reviewed journals (e.g. Oecologia) require figure panel labels to be inside of plot borders (although they seem to enforce these requirements inconsistently). It would be nice if there were an option like
theme(plot.tag.position = "topleftinner")
to place a label at the upper left corner of the inside of plot borders. Currently, I think I have to kludge this by tweakingtheme(plot.tag = element_text(vjust = , hjust = )
, but it's inconsistent, so I have to do this tweaking for every panel individually. Maybe there's an easier way that I don't know about?Related to: https://github.com/thomasp85/patchwork/issues/222
Created on 2020-12-15 by the reprex package (v0.3.0)