positioning legend when using plot.title.position="plot"

Hello,

recently a new theme argument was introduced into ggplot which allows to align the title, subtitle and caption with the plot's (and not the panels) outer margin: plot.title.position="plot" etc.

Is there any way how to move also the legend to e.g. the very left (as in my example below)? Many thanks!

library(tidyverse)

mtcars %>% 
  rownames_to_column(., var="carname") %>% 
  ggplot()+
  labs(title="my tile",
       subtitle="my subtitle",
       caption="my caption")+
  geom_bar(aes(x=carname,
               y=wt,
               fill=as.factor(cyl)),
           stat="identity")+
  coord_flip()+
  facet_wrap(vars(cyl),
             scales="free_y")+
  theme(legend.position = "top",
        legend.justification = "left",
        plot.title.position = "plot",
        plot.caption = element_text(hjust=0),
        plot.caption.position = "plot")

Created on 2020-01-15 by the reprex package (v0.3.0)

2 Likes