Reputation: 175
ggplot(mtcars, aes(x = mpg,
y = wt,
size = hp,
colour = as.factor(cyl))) +
geom_point() +
theme(legend.direction = "vertical",
legend.box = "horizontal",
legend.position = "bottom")
gives me
How can I produce the legend in a way, where the cyl-label remains vertical and the hp categories are arranged horizontally?
Upvotes: 3
Views: 3233
Reputation: 13833
You can individually control legends via guides(...)
:
ggplot(mtcars, aes(x = mpg,
y = wt,
size = hp,
colour = as.factor(cyl))) +
geom_point() +
theme(legend.direction = "vertical",
legend.box = "horizontal",
legend.position = "bottom") +
guides(size=guide_legend(direction='horizontal'))
Upvotes: 4