Closed
Description
Is there an option to control how multiple legends are laid out inside the legend box (horizontal vs vertical)? I wasn't able to find one, but maybe I'm just missing something. The layout direction seems to change based on where the legend is placed. I would like the legend to look like when I place the legend on top of the plot but place it inside, with individual legends laid out vertically but the legends arranged horizontally next to each other. Is this possible?
library(ggplot2)
ggplot(mtcars) +
aes(disp, mpg, fill = hp, shape = factor(cyl), size = wt) +
geom_point() +
theme(
legend.position = "top",
legend.direction = "vertical"
)
ggplot(mtcars) +
aes(disp, mpg, fill = hp, shape = factor(cyl), size = wt) +
geom_point() +
theme(
legend.position = "inside",
legend.direction = "vertical"
)
ggplot(mtcars) +
aes(disp, mpg, fill = hp, shape = factor(cyl), size = wt) +
geom_point() +
theme(
legend.position = "inside",
legend.direction = "horizontal"
)
Created on 2024-07-26 with reprex v2.0.2
Metadata
Metadata
Assignees
Labels
No labels