I've tried the solutions from the links, which are to use units()
and patchwork
respectively, but those doesn't work with geom_col
and return the next distorted legend
CodePudding user response:
This one is from one of the mentioned so pages
CodePudding user response:
The legend.margin argument allows you to edit the size of the legend using the margin
function
library(gapminder)
ggplot(gapminder |>
filter(continent %in% c("Americas", "Europe"), country %in% c("Chile", "Spain")))
geom_col(aes(x = country, y = lifeExp, fill = continent), position = "dodge")
theme(legend.position = "bottom",
legend.background = element_rect(fill = "gray"),
legend.margin = margin(0,6,0,6, "cm"))