Closed
Description
I have recently installed the ggplot2
3.5.0 release, and after reading the new features added to the Legends Placement, I was very curious to know if it is possible to have multiple inside legends (position = "inside"
) at different positions by using the new legend.position.inside
argument for each guide. For example, cty
legend at bottom-right and cyl
at top-right. However, it does not work.
library(ggplot2) # Create Elegant Data Visualisations Using the Grammar of Graphics CRAN v3.5.0
ggplot(mpg, aes(displ, hwy, shape = drv, colour = cty, size = year)) +
geom_point(aes(alpha = cyl)) +
guides(
colour = guide_colourbar(position = "inside",
theme = theme(legend.position.inside = c(1, 0))),
size = guide_legend(position = "top"),
alpha = guide_legend(position = "inside",
theme = theme(legend.position.inside = c(0, 1))),
shape = guide_legend(position = "left")
)
It seems only works by using the global theme’s legend.position.inside
arguments, grouping both legends at the same position, but for now is not possible to not place them separately.