How to force a legend inside a plot to be horizontal and not vertical?
ggplot2, legend, r
Solution
You get horizontal legend by adding argument `legend.direction="horizontal"` inside the `theme()` or `opts()`
theme(legend.direction="horizontal")
Older versions
opts(legend.direction="horizontal")
Problem
I'd like the legend inside the plot to be horizontal (each one is beside each other not one is above the other) Is there a way to change from vertical to horizontal? Example: ``` mtcars$cyl <- factor(mtcars$cyl, labels=c("four","six","eight")) ggplot(mtcars, aes(x=wt, y=mpg, colour=cyl)) + geom_point(aes(colour=cyl)) + opts(legend.position = c(0, 1), title="Legend placement makes me sad") ```