Skip to content

Tag positioning not working? #2882

Closed
Closed
@anhttdang

Description

@anhttdang

Hello,

I used hjust and vjust for plot.tag but it didn't seem to work. Is it an intended behavior? How can I move the tag away from the plot region especially when placing it on the right?

Thank you!

library(dplyr)
library(ggplot2)

mpg <- mpg %>% 
  filter(cyl == 4 | cyl == 8)

p <- ggplot(mpg, aes(displ, cty)) + 
  geom_point() +
  facet_grid(cols = vars(cyl)) +
  labs(tag = 'A)') +
  theme_minimal() +
  theme(plot.caption = element_text(size = 14)) +
  theme(plot.margin = margin(t = 20, r = 20, b = 20, l = 20))

p1 <- p +
  labs(caption = "top") +
  theme(plot.tag.position = 'top')

p2 <- p +
  labs(caption = "top, vjust = 1, hjust = 1") +
  theme(plot.tag.position = 'top',
        plot.tag = element_text(vjust = 1, hjust = 1))

p3 <- p +
  labs(caption = "right") +
  theme(plot.tag.position = 'right')

p4 <- p +
  labs(caption = "right, vjust = 1, hjust = 1") +
  theme(plot.tag.position = 'right',
        plot.tag = element_text(vjust = 1, hjust = 1))

library(patchwork)
(p1 | p2)

(p1 | p3) / (p2 | p4)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions